我有这条线
$sql_events = mysql_query("SELECT team FROM weekpicks WHERE whatweek='$totalnoOfWeek'-1 and team in ( SELECT team1 FROM weekslosers WHERE whatweek='$totalnoOfWeek'-1 ) ORDER BY 'username' asc ")
它可以工作,但我还需要检查一下team2,team3等。我以为我可以做下面的事情,但是不起作用。似乎停在team1
$sql_events = mysql_query("SELECT team FROM weekpicks WHERE whatweek='$totalnoOfWeek'-1 and team in ( SELECT team1 FROM weekslosers WHERE whatweek='$totalnoOfWeek'-1 ) or ( SELECT team2 FROM weekslosers WHERE whatweek='$totalnoOfWeek'-1 ) ORDER BY 'username' asc ")
还是应该以其他方式完成?
我要做的是将球队从桌上的周盘中拿出来,并与桌上的周盘输者进行比较,而周盘输者表中最多可以有8个输球队,所以如果您的球队是8个输之一,我需要将其列出。
最佳答案
SELECT team
FROM weekpicks
INNER JOIN weekslosers ON weekpicks.whatweek = weekslosers.whatweek
WHERE weekpicks.whatweek = (whatever) AND team IN (weekslosers.team1, weekslosers.team2)
另外,您应该考虑从mysql_ *过渡到mysqli或PDO。