0

My query :

SELECT * FROM game_tbl WHERE ( `player_o` = 1 OR `player_x` = 1 ) AND ( `player_o` = NULL OR `player_x` = NULL )

game_tbl : enter image description here

use: mysql

and the result is zero rows, i want the 'game1'. Well i guess i can use other query but, important to my to understand right my wrong sql syntax, thank you all

1 Answer 1

2

Try using IS NULL instead of = NULL, e.g.:

SELECT * 
FROM game_tbl 
WHERE (`player_o` = 1 OR `player_x` = 1) AND (`player_o` IS NULL OR `player_x` IS NULL)

Here's MySQL's documentation on working wiith NULL values.

To test for NULL, use the IS NULL and IS NOT NULL operators.

You cannot use arithmetic comparison operators such as =, <, or <> to test for NULL.

Sign up to request clarification or add additional context in comments.

1 Comment

So embarrassing you'r right tank you for you fix my syntax

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.