0

My query is

SELECT partnumber, side FROM crpt_admin_orders_partnumbers
WHERE order_id = 198 AND side != 'B'

so in side column expected value is NULL, 'A', 'B'. I need to get all Null and 'A' records, but this query is not returning any results.

if I run

SELECT partnumber, side FROM crpt_admin_orders_partnumbers
WHERE order_id = 198 AND side is NULL

then it returns me 2 records.

What is the possible cause for this not working. And what is the solutions. Thanks in advance

Aamir Mahmood
  • 2,704
  • 3
  • 27
  • 47

1 Answers1

2

You need to test for NULL specifically, you can't use mathematical operators.

http://dev.mysql.com/doc/refman/5.0/en/working-with-null.html

The NULL value can be surprising until you get used to it. Conceptually, NULL means “a missing unknown value” and it is treated somewhat differently from other values.

Jaydee
  • 4,138
  • 1
  • 19
  • 20