Jump to content

[SOLVED] ! Not Empty help with query?


Mr Chris

Recommended Posts

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

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

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.

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.