Solved

Simple SQL Query Problem

Posted on 2012-04-02
6
290 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
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

808 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