Thursday, 19 September 2013

mySQL joining data from a diffrent table

mySQL joining data from a diffrent table

Alright, I'm pulling a list of users from a mySQl database then I'm
looking for group assignment in a different table. if they are assigned to
multiple groups multiple rows are returned as they should.
My question is how can I concat the group names into one column of the
results.
SELECT `u`.`ID`,CONCAT(`First-Name`," ",`Last-Name`) as
`Name`,`g`.`Group-Name` FROM `application-users` AS `u`JOIN `groups` AS
`g` ON (`g`.`Assigned-Users` LIKE CONCAT("%|",`u`.`ID`,"|%") )WHERE
`u`.`Status` = "Active" && `u`.`Type` = "Business Development" ORDER BY
`First-Name` ASC
Thanks in advance!

No comments:

Post a Comment