我想基于messageid group_concate image_id和small_pic_path路径。 但是group concate显示了所有image_id和第一个messageid的路径
如何解决此问题
没有group_concate它正常工作
SELECT user_messages.messageid,user_messages.message,
user_messages.sentby,user_messages.visibility,
post_images.image_id,
post_images.small_pic_path
FROM user_messages
INNER JOIN smsusers ON
user_messages.SENTBY = smsusers.id
INNER JOIN profile_pic ON
user_messages.SENTBY = profile_pic.userid
left outer JOIN post_images ON
user_messages.messageid=post_images.messageid
WHERE user_messages.userid='1';
显示正确的输出Demo is
我想基于user_messages的messageid group_concate image_id,post_pict_path的帖子图片 哪个不能正常工作
SELECT user_messages.messageid,user_messages.message,
user_messages.sentby,user_messages.visibility,
GROUP_CONCAT( post_images.image_id SEPARATOR ';')
as Image_id,
GROUP_CONCAT( post_images.small_pic_path SEPARATOR ';')
as Image_path
FROM user_messages
INNER JOIN smsusers ON
user_messages.SENTBY = smsusers.id
left outer JOIN post_images ON
user_messages.messageid=post_images.messageid
WHERE user_messages.userid='1';
答案 0 :(得分:0)
您缺少GROUP BY
条款,
GROUP BY user_messages.messageid,
user_messages.message,
user_messages.sentby,
user_messages.visibility