SELECT * FROM timetable
LEFT JOIN user
ON timetable.id = user.id
WHERE timetable.id = 1
//this only display 1 column's name from user table
//id partner name time
//1 2 Ben 2015-05-17
//user
id name
1 Ben
2 Lisa
//timetable
id partner time
1 2 123456484
//What I need is display like this
Ben Lisa 2015-05-17
I have a 2 tables user and timetable
user table store id and name
timetable store id which partner group together
Now, I need to join these 2 tables together and display their name
I try to join but it only shows one column's name
anyone know how to display 2 columns?
your explanation is not clear. But here is my guess:
SELECT
u.name,
p.name,
t.time
FROM timetable t
LEFT JOIN user u
ON timetable.id = u.id
LEFT JOIN user p
ON timetable.partner = p.id
WHERE timetable.id = 1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.