MySQL duplicate names to be returned -
i have table next syntax:
| id | institution_course1_id | institution_course2_id |
where application1_id , application2_id references same table. need values of both (so in other words want retrieve name of each application)
i tried bring together tables still receiving 1 name in results. here sql use:
select * `client_applications` left bring together `institution_courses` `name1` on `client_applications`.`institution_course1_id`=`name1`.`id` left bring together `institution_courses` `name2` on `client_applications`.`institution_course2_id`=`name2`.`id` `client_applications`.`client_id`=?
is there way me homecoming in results rows client_applications , have 2 seperate added keys "name1" , "name2" based on above?
i guessing problem application reading results. seek putting in different aliases ("column names") 2 names:
select ca.*, name1.name name1, name2.name name2 `client_applications` ca left bring together `institution_courses` `name1` on ca.`institution_course1_id` = `name1`.`id` left bring together `institution_courses` `name2` on ca.`institution_course2_id` = `name2`.`id` ca.`client_id` = ?;
otherwise query looks fine (although added alias first table well).
mysql
No comments:
Post a Comment