Mr Chris Posted July 26, 2007 Share Posted July 26, 2007 Hi Guys, I have a query, but it has three AND statements: SELECT r.match_date, th. team_name AS home_team, ta. team_name AS away_team, r.team_one_score, r.team_two_score, r.competition, r.fixture_id, r.team_one_id, r.team_two_id FROM results r INNER JOIN teams th ON r.team_one_id = th.team_id INNER JOIN teams ta ON r.team_two_id = ta.team_id WHERE r.match_date > CURDATE() AND r.team_one_score='' AND r.team_two_score='' AND th.team_id='1' OR ta.team_id='1' ORDER BY match_date ASC LIMIT 1 Now if I get rid of the AND statements the first part of the query works. Is there a better way I can use my AND statements to get this query to work? Thanks Quote Link to comment Share on other sites More sharing options...
Illusion Posted July 26, 2007 Share Posted July 26, 2007 r u sure that r.team_one_score and team_two_score is equal to one space character ,if they are NULL values then the better way is ......r.team_one_score IS NULL AND r.team_two_score IS NULL AND ....... Quote Link to comment Share on other sites More sharing options...
pikemsu28 Posted July 26, 2007 Share Posted July 26, 2007 try using parenthasis SELECT r.match_date, th. team_name AS home_team, ta. team_name AS away_team, r.team_one_score, r.team_two_score, r.competition, r.fixture_id, r.team_one_id, r.team_two_id FROM results r INNER JOIN teams th ON r.team_one_id = th.team_id INNER JOIN teams ta ON r.team_two_id = ta.team_id WHERE r.match_date > CURDATE() AND r.team_one_score='' AND r.team_two_score='' AND (th.team_id='1' OR ta.team_id='1') ORDER BY match_date ASC LIMIT 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.