我有2个表,即chatsTable和adsTable ...在chatsTable中,我有col_a_id(广告的外键)和col_message。 在广告中,我有多个列,例如col_title,col_desc。我需要加入这些表并选择不同的值。
SELECT ads.id,col_title,col_img,col_status FROM `adsTable` AS ads
RIGHT JOIN `ChatsTable` AS chat ON (chat.a_id = ads.id)
WHERE (`sender` = '1' OR `reciever` = '1') GROUP BY ads.id
这对我有用,但是我想在此表中合并col_message。或类似的东西。
答案 0 :(得分:0)
您可以尝试以下操作-使用不同的
SELECT distinct ads.id,col_title,col_img,col_status,col_message
FROM `adsTable` AS ads
RIGHT JOIN `ChatsTable` AS chat ON chat.a_id = ads.id
WHERE (`sender` = '1' OR `reciever` = '1')