Solved

Simple SQL Query Problem

Posted on 2012-04-02
6
293 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:lukasfrei
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 37794816
Change it to

Wcat IS NULL
0
 
LVL 61

Expert Comment

by:mbizup
ID: 37794823
Ignore my last post.
0
 
LVL 9

Accepted Solution

by:
mimran18 earned 500 total points
ID: 37794825
Here we go,

SELECT  wid, wcat FROM watches WHERE ISNULL(wcat,'') != 'o' AND wid = 70073
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 37794837
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
0
 
LVL 7

Expert Comment

by:waltersnowslinarnold
ID: 37794889
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
0
 

Author Closing Comment

by:lukasfrei
ID: 37794956
wow, thanks for help to all of you
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question