Re: MySQL, get joined records separated by commas
Posted: Fri Nov 28, 2008 8:33 am
Here's my query:
And I've tried moving the 2 LEFT JOIN `countries` to just before the WHERE as well but I keep getting the same error:
Not unique table/alias: 'countries'
I really think there's some syntax I need to use here that I don't know about
Any more hints VladSun?
Cheers, B
Code: Select all
SELECT `companies`.`address1`, `companies`.`address2`, `companies`.`address3`, `companies`.`company_name`, `companies`.`county_state`, `companies`.`postcode_zip`, `companies`.`town_city`, `companies`.`geo`, `contacts`.`address1_contact`, `contacts`.`address2_contact`, `contacts`.`address3_contact`, `contacts`.`contact_name`, `contacts`.`county_state_contact`, `contacts`.`mail_contact`, `contacts`.`postcode_zip_contact`, `contacts`.`reg_stamp`, `contacts`.`town_city_contact`, `contacts`.`geo_contact`, GROUP_CONCAT(`tags`.`name` ORDER BY `tags`.`name` ASC SEPARATOR ',') AS `classifications` FROM `contacts` LEFT JOIN `countries` ON `contacts`.`geo`=`countries`.`geo` LEFT JOIN `countries` ON `companies`.`geo`=`countries`.`geo` LEFT JOIN `companies` USING(`company_id`) LEFT JOIN `tags_data` ON `companies`.`company_id`=`tags_data`.`company_id` LEFT JOIN `tags` ON `tags_data`.`tag_id`=`tags`.`tag_id` AND `tags`.`category`='OE FRANCHISE' WHERE `contacts`.`mag_amd`='FREE' GROUP BY `contacts`.`contact_id` ORDER BY `companies`.`geo`, `companies`.`company_name`, `contacts`.`contact_name` ASCNot unique table/alias: 'countries'
I really think there's some syntax I need to use here that I don't know about
Any more hints VladSun?
Cheers, B