MySQL 一对多查询,合并多的一方的信息
2015-11-27 20:49
579 查看
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
相关文章推荐
- mysql 常用操作
- mysql复制表结构及数据
- mysql数据库引擎myisam与innodb
- mysql表达式中decimal的设置,和length的设置
- mysql如何开启远程连接
- 给mysql用户重新设置权限后报错
- Ubuntu下mysql解决中文乱码
- 二进制方式快速安装MySQL数据库
- mysql创建定时器(event),查看定时器,打开定时器,设置定时器时间
- mysql修改数据库、表、字段、库的字符集
- Mysql查询语句性能优化
- Ubuntu下允许mysql远程连接
- mysql分页丢数据的分析
- 解决 c3p0 和 MySQL 集成情况下,连接长时间闲置后重新使用时报错的问题
- MYSQL数据库远程登录及权限设置
- 简单讲解MySQL的数据库复制方法
- mysql 授权 user@'%' 为什么登陆的时候localhost 不行呢???
- ubuntu下终端操作MySql数据库的命令
- mysql的几种隐式转化
- MySQL对数据库数据进行复制的基本过程详解