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
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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.