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 Link to comment https://forums.phpfreaks.com/topic/61865-three-and-statements/ 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 ....... Link to comment https://forums.phpfreaks.com/topic/61865-three-and-statements/#findComment-308200 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 Link to comment https://forums.phpfreaks.com/topic/61865-three-and-statements/#findComment-308209 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.