Mr Chris Posted July 17, 2007 Share Posted July 17, 2007 Hi Guys, Wondering if someone can help me with a query that’s confusing me. If I want to check for empty values on a column I’d do: Select * FROM results WHERE team_one_score !=' ' LIMIT 1; Which is fine, but trying to run this query via a joined table: SELECT th.team_name, ta.team_name, r.team_one_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.team_one_score !=' ' AND team_one_id='1' OR team_two_id='1' LIMIT 1; My query ignores the empty rule? Can anyone help? Thanks Chris Link to comment https://forums.phpfreaks.com/topic/60353-solved-not-empty-help-with-query/ Share on other sites More sharing options...
Illusion Posted July 17, 2007 Share Posted July 17, 2007 !=' ' is not empty value it is equal to two spaces if u want to check for NULL values u need to give the condition like !='' or team_one_score is NULL. Link to comment https://forums.phpfreaks.com/topic/60353-solved-not-empty-help-with-query/#findComment-300263 Share on other sites More sharing options...
Mr Chris Posted July 17, 2007 Author Share Posted July 17, 2007 Thanks, But that was my typo and i've tried Null as well: SELECT th.team_name, ta.team_name, r.team_one_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.team_one_score != Null AND team_one_id='1' OR team_two_id='1' LIMIT 1; And SELECT th.team_name, ta.team_name, r.team_one_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.team_one_score !='' AND team_one_id='1' OR team_two_id='1' LIMIT 1; And yet it still ignore's the NOT empty rule? Any other ideas please? Thanks Link to comment https://forums.phpfreaks.com/topic/60353-solved-not-empty-help-with-query/#findComment-300294 Share on other sites More sharing options...
Illusion Posted July 17, 2007 Share Posted July 17, 2007 that should be WHERE r.team_one_score IS NOT NULL and WHERE r.team_one_score='' it all depends on how u inserted the values in that column if u inserted NULL value above two will work or if u inserted some spaces give condition according to that. Link to comment https://forums.phpfreaks.com/topic/60353-solved-not-empty-help-with-query/#findComment-300302 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.