MySQL 一对多查询,合并多的一方的信息

select
		jdf_share.id_,jdf_share.title,
		(select nickname from jdf_user where jdf_share.user_id_ = jdf_user.id_) as nickname , GROUP_CONCAT(jdf_file.imgurl_big) as imgurlbigs,GROUP_CONCAT(jdf_file.imgurl) imgurls,
		if(isnull((select jdf_user_share_zan.tmstamp from jdf_user_share_zan
		where jdf_user_share_zan.user_id_=1
		and jdf_user_share_zan.share_id_=jdf_share.id_)),0,1)
		as is_zan,IF (isnull((select jdf_collection.tmstamp from
		jdf_collection where jdf_collection.user_id_=1
		 and jdf_collection.fk_id_=jdf_share.id_)),0,1)
		as is_collect
		from
		jdf_share,jdf_user,jdf_file
		where jdf_share.user_id_ = jdf_user.id_
and 
jdf_file.flag=1
and 
jdf_file.fk_id = jdf_share.id_
GROUP BY jdf_file.fk_id

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页