| |

VerySource

 Forgot password?
 Register
Search
View: 730|Reply: 3

Simple question. Queries for multiple category names

[Copy link]

1

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-3 23:30:01
| Show all posts |Read mode
Two tables T_resume_language, T_language_sort
The first table has three fields. The second table is the category table.
Now I want to find out if the name of the category must be written three times like this.
Is there any good way. This doesn't look very good.
select languageId1, languageId2, languageId3
, (select a.cname from T_language_sort as a, T_resume_language as b where a.code = b. languageId1 and b. [resumeid] = @ id) as language1,
(select a.cname from T_language_sort as a, T_resume_language as b where a.code = b. languageId2 and b. [resumeid] = @ id) as language2,
(select a.cname from T_language_sort as a, T_resume_language as b where a.code = b. languageId3 and b. [resumeid] = @ id) as language3
from T_resume_language as a where [resumeid] = @ id
Reply

Use magic Report

0

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-5-17 17:00:01
| Show all posts
select a.languageId1, a.languageId2, a.languageId3, b.cname, c.cname, d.cname
from T_resume_language a
left join T_language_sort b on a.languageId1 = b.code
left join T_language_sort c on a.languageId2 = c.code
left join T_language_sort d on a.languageId3 = d.code
where a. [resumeid] = @id
Reply

Use magic Report

0

Threads

49

Posts

35.00

Credits

Newbie

Rank: 1

Credits
35.00

 China

Post time: 2020-5-18 08:45:01
| Show all posts
select languageId1, languageId2, languageId3,
b.cname as language1, c.cname as language2, d.cname as language3
from T_resume_language as a inner join T_language_sort as b on b.code = a. languageId1
                            inner join T_language_sort as c on c.code = a. languageId2
                            inner join T_language_sort as d on d.code = a. languageId3
where [resumeid] = @ id
Reply

Use magic Report

1

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-5-19 10:30:01
| Show all posts
I understand everyone's meaning, that is to say, there is no other good way to only inline a few times.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list