简体   繁体   English

对不同的表使用两个WHERE语句

[英]Using two WHERE statements for different tables

I have build a follow system but that system displays all members who are even temporarily deactivated, for disabling deactivated members from showing in areas such as followers or following I have added a column 'closed' in members table which is initially set to no and when a member wants to temporarily deactivate his profile this no is updated to yes. 我已经建立了一个关注系统,但是该系统显示所有甚至被暂时停用的成员,以禁止停用的成员在关注者或跟随者等区域显示。我在成员表中添加了“关闭”列,该列最初设置为no ,何时设置成员想要暂时停用其个人资料,此“否”更新为“是”。 Now my idea is to join the select statement which selects members followed or following from follow table with members with the column closed set to no in members table so my system displays only activated members. 现在,我的想法是加入select语句,该语句从follow表中选择跟随的成员或从follow表中选择成员,并且在members表中将closed列的成员设置为no ,因此我的系统仅显示激活的成员。

My select statement is: 我的选择语句是:

SELECT * FROM follow WHERE uid=:memberid

I tried but get syntax error for this: 我试过但是得到语法错误:

SELECT * FROM follow INNER JOIN members on members.memberid=follow.uid WHERE uid=:memberidid WHERE closed=no

而不是使用WHERE两次,你可以使用AND对“第二” WHERE -clause。

SELECT * FROM `follow` INNER JOIN `members` ON `members`.`memberid` = `follow`.`uid` WHERE `uid` = :memberidid AND `closed` = "no"
SELECT * FROM 
follow INNER JOIN members 
on members.memberid=follow.uid 
WHERE follow.uid=follow.memberid 
AND members.closed='no'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM