June 16, 2008 at 1:28 am
I am having 2 tables
Primary table (test1) which contains two columns
ID
Name
Secondary table (test2)
id1,id2,id3
All the id1,id2,id3 are PK in test1.ID.
I need to select NAME from test1 based on id1,id2,id3 from test2.
June 16, 2008 at 5:00 am
I'm not sure I got your question right, but I hope so... as I understand it:
You need to start from table2, and then join the table1 (the one with names) several times under different aliases.
Hint: Be careful not to exclude rows, where some of the 3 columns have a value, and some are empty.
If you don't succeed, post what you tried and what was your problem, then we can discuss it greater detail.
June 16, 2008 at 5:27 am
Thanks
test1 contains
100 Alex
101 John
102 Gavin
103 Ashih
tes2 contains
100,101,102
I need to select names from test1 based on id available in tes2 (id in test1 is FK to test2)
June 16, 2008 at 5:39 am
Fine, seems I got it right - so you already have my answer.
Did you try it? Were you successful?
If not, what was your problem?
You see, this is a very simple problem, so I guess you are learning SQL. The best way to learn is to try it yourself. If you find the solution, you will remember it (at least for some time) 😎
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply