Solved

Simple SQL Query Problem

Posted on 2012-04-02
6
291 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
Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

 
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

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.

Question has a verified solution.

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

Suggested Solutions

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

763 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