中易网

Sql 三表联查问题

答案:2  悬赏:30  
解决时间 2021-04-28 04:31
  • 提问者网友:萌萌小主
  • 2021-04-27 20:57
SELECt username,Userfaceid,FeelingHot, Feelingzhan,Feelingcontent,Feelingid,Feelingdate FROM [CtFeelings] a,CtUsers c,CtFriends B
where B.Friendid=a.hostid and a.Hostid=c.Userid and B.hostid=101
select username,Userfaceid,FeelingHot, Feelingzhan,Feelingcontent,Feelingid,Feelingdate FROM [CtFeelings] a,CtUsers c,CtFriends B
where B.Hostid=a.Hostid and a.Hostid=c.Userid and a.Hostid=101
怎么 将这两条SQL语句合并为一条?谢谢

也就是,我要同时查询 用户表,好友表和心情表的信息, 查询内容为用户自己和用户自己好友所发送的心情信息。 我用到的查询条件为 用户的ID 也就是Hostid
最佳答案
  • 二级知识专家网友:专属的偏见
  • 2021-04-27 22:19
--如下
SELECt username,Userfaceid,FeelingHot, Feelingzhan,Feelingcontent,Feelingid,Feelingdate FROM [CtFeelings] a,CtUsers c,CtFriends B where B.Friendid=a.hostid and a.Hostid=c.Userid and (B.hostid=101 or a.Hostid=101)
全部回答
  • 1楼网友:魅世女王
  • 2021-04-27 23:15
select s.stuid,s.stuname,b.bid,b.title,bo.t_time from student s,borrow bo,book b where s.major='计算机' and bo.t_time>='2007-12-15' and bo.t_time=<'2008-1-8'and s.stuid = bo.stuid and bo.bid = b.bid
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息