Joing the Tables to get the required data, I got three tables which are connected and i want to get the data from the 3rd table

StackOverflow https://stackoverflow.com/questions/23308073

문제

My First Table Name is UserClient and it contains UserTrainerID. Using UserTrainerID, Second Table is UserTrainer and it contains UserID (I want to Know the UserID of UserTrainer using UserTrainerID), now third table is User where with the help of userID I want to get the UserName.

도움이 되었습니까?

해결책

Select a.username from t3 a,t2 b,t1 c 
    where a.userid=b.userid and b.UserTrainerID= c.UserTrainerID ;

다른 팁

Here is syntax to join three tables, I hope you will be able to join your tables accordingly:

SELECT t1.col, t3.col FROM table1 
             join table2 ON table1.primarykey = table2.foreignkey
             join table3 ON table2.primarykey = table3.foreignkey

Read more: http://javarevisited.blogspot.com/2012/11/how-to-join-three-tables-in-sql-query-mysql-sqlserver.html#ixzz2zyYzv3pD

or SQL Inner-join with 3 tables?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top