【发布时间】:2016-02-22 17:38:43
【问题描述】:
我是 Asp.net 的新手 现在我想尝试开始一个社交网络项目
我有 3 张桌子
用户
用户名 -用户名 -电子邮件 -密码 -姓名 -个人资料图片
发帖
-Postid -Content -Postdate -Userid
好友列表
Friendlistid - userid -friendid -status
我想加载我朋友和我自己的帖子
这是我的sql代码
select b.userid, a.Friendid, c.name, b.postid, b.Content, b.postdate, c.profilepic
from friendlist a
left join [user] c on a.friendid = c.userid
left join post b on a.friendid = b.userid
where a.userid = 1 AND a.Status = 1 OR a.Userid = 1
ORDER BY postid desc
我面临的问题是我的帖子会重复
例如,我的好友列表有 3 个好友,我的每个帖子都会重复 3 次,而我的好友帖子保持正常。
这个sql代码有什么解决办法吗?
【问题讨论】:
-
您需要多个查询。
-
不要以纯文本形式存储密码。