Click here to Skip to main content
15,908,618 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have three tables

A,B,C

A columns id,d,e
B columns id,f,g
C columns id,h,i


here three columns in id is same

i need one id and three tables information

output

id, d,e,f,g,h

how to write command
Posted

You need to join the tables. For tutorial, see SQL Joins[^]

So your statement could be something like
SQL
select table1.id, table1.d, table2.f...
from table1 inner join table2 on table1.id = table2.id
            inner join table3 on table2.id = table3.id
 
Share this answer
 
Comments
2011999 17-May-12 7:34am    
only three tables id get it but remaining data is not get it
Wendelius 17-May-12 7:46am    
Do you mean you don't have matching rows on each table. If that's the case, use outer join instead of inner join.
Maciej Los 17-May-12 7:50am    
If you would like to get output: id, d,e,f,g,h , the above query is correct.
Maciej Los 17-May-12 7:51am    
Good answer, my 5!
Wendelius 17-May-12 7:59am    
Thanks :)
You have to use join.
Study about joins.
 
Share this answer
 
A,B,C

A columns id,d,e
B columns id,f,g
C columns id,h,i



select e.id,e.coloumn1,e.coloumn2,e1.coloumn1,e1.coloumn2,e2.coloumn1,e2.coloumn2 from A e join
B e1 on e.id=e1.id join C e2 on e.id=e2.id


Here e,e1,e2 are alises of table and
e.coloumn1 contain d
e.coloumn2 contain e
e1.coloumn1 contain f
etc............
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900