简体   繁体   中英

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. 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.

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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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