I have a table named demo1 with primary_id is ID and the values are as below
ID Name
1 A
2 B
3 C
4 D
5 E
Another table is demo2 which has following data with the primary key ID1
ID1 I1 P1 P2
10 1 2 3
20 2 1 5
Values of I1, P1, and P2 is from field ID of table demo1
Now i have the value of ID1 of demo2 table and I have to get value of Name field of demo1 table with respect to ID : I1, P1, and P2
for example if i know 10(value of ID1) then I should get the output as follows
ID1 I1_NAME I2_NAME I3_NAME
10 A B C
What could be the sql query for this?
Thanks
1 Answer