SELECT `a`.`department`, `a`.`category`, `a`.id,
(SELECT group_concat(t_0) FROM images WHERE ad_id=a.id) t_0,
(SELECT group_concat(t_1) FROM images WHERE ad_id=a.id) t_1,
(SELECT group_concat(t_1) FROM images WHERE ad_id=a.id) t_8
FROM `ads` AS `a`
WHERE (a.department = 1) AND (a.category = 12) AND (a.charged=1)
ORDER BY `a`.`id` DESC
Is there better solution than this? I need to have all images from images table for each a.id(ad_id)
Thanks :)
edit...
aha it seems this is working:
SELECT `a`.`department`, `a`.`category`, `a`.id, group_concat(t_0), group_concat(t_1), group_concat(t_8)
FROM `ads` AS `a`
LEFT JOIN images i ON i.ad_id=a.id
WHERE (a.department = 1) AND (a.category = 12) AND (a.charged=1)
GROUP BY a.id DESC
Don't know if this is right solution thou... :)