MySQL get same parameters with different key -
i have 2 tables:
users:
id first_name last_name -------------------------------- 1 john smith 2 adam jones
user_planner_tasks:
id moderator user_id ----------------------------- 1 1 2 2 2 1
i display each task 'user_planner_tasks' table. while @ same time displaying first , last name of moderator , user corresponding id's.
i wish have this:
id moderator first_name last_name user_id first_name last_name ------------------------------------------------------------------------------------- 1 1 john smith 2 adam jones
i know have use join of sort cannot, life of me, figure out. reference great!
select t.id, t.moderator, m.first_name, m.last_name, t.user_id, u.first_name, u.last_name user_planner_tasks t left join users u on t.user_id = u.id left join users m on t.moderator = m.id
Comments
Post a Comment