首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

mysql查询语句求解,该怎么处理

2012-04-25 
mysql查询语句求解user_py 三个字段 id userName(用户) py(用户的朋友)user 四个字段 uid userName(用户)

mysql查询语句求解
user_py 三个字段 id userName(用户) py(用户的朋友)
user 四个字段 uid userName(用户) userpwd(密码) pic(相片)
user_xq 三个字段 id userName (用户)content(心情内容)

要求只显示登录用户的朋友中的心情等心情,非朋友不显示,输出心情content,该心情用户的相片pic,并且按照心情ID从大到小排列,

[解决办法]
你这样用全链接的可能会有问题哦,会有重复行或者空行
更加严谨的写法的话推荐用 left join 或者 right join
[解决办法]

#1楼select C.content,B.pic
from user_py A,user B,user_xq C
where A.py =B.username and A.py=C.userName and A.username=???
order by C.id desc

热点排行