Link to home
Start Free TrialLog in
Avatar of lukasfrei
lukasfreiFlag for Switzerland

asked on

Simple SQL Query Problem

What is wrong in this query? :-)


Row:
wid = 70073, wcat = NULL


SELECT  wid, wcat FROM watches WHERE wid = 70073
1 row affected


SELECT  wid, wcat FROM watches WHERE wcat != 'o' AND wid = 70073
0 rows affected

See also screenshots attached.
sql01.png
sql02.png
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Change it to

Wcat IS NULL
Ignore my last post.
ASKER CERTIFIED SOLUTION
Avatar of mimran18
mimran18
Flag of United Arab Emirates image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
what is datatype of wcat

try

SELECT  wid, wcat FROM watches WHERE wcat <> 'o' AND wid = 70073

or

SELECT  wid, wcat FROM watches WHERE wcat not like  'o' AND wid = 70073
You should handle NULL properly, NULL is always a trouble maker;

Use the below sample, this should help you;

SELECT  wid, wcat FROM watches WHERE ISNULL(wcat,'') != 'o' AND wid = 70073

OR

SELECT  wid, wcat FROM watches WHERE ISNULL(wcat,'') <> 'o' AND wid = 70073
Avatar of lukasfrei

ASKER

wow, thanks for help to all of you