Reputation: 61
I have this line
$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 ")
It works, but I need it to also check team2, team3 and so on. I thought I could do something like the following, but it does not work. it appears to stop at 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 ")
Or should this be done a different way?
What I am looking to do is take the team from the table weekpicks and compare it to the teams in table weekslosers and the weekslosers table could have up to 8 losing teams so if your team is one of the 8, I need it to be listed.
Upvotes: 0
Views: 20
Reputation: 5668
SELECT team
FROM weekpicks
INNER JOIN weekslosers ON weekpicks.whatweek = weekslosers.whatweek
WHERE weekpicks.whatweek = (whatever) AND team IN (weekslosers.team1, weekslosers.team2)
Also, you should look into transitioning away from mysql_* and towards mysqli or PDO.
Upvotes: 1