Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

How can i get all names where field2 is not equal to 'x'

 
   Database Forums (Home) -> Connect RSS
Next:  I cannot Create an ODBC source for SQL server 200..  
Author Message
Bart

External


Since: Feb 02, 2008
Posts: 2



(Msg. 1) Posted: Tue Feb 12, 2008 5:00 am
Post subject: How can i get all names where field2 is not equal to 'x'
Archived from groups: microsoft>public>sqlserver>connect (more info?)

Hi,

How can i get all names where field2 is not equal to 'x'?

I did this: select name from mytable where not (field2='x')

result: only joe is fetched

this is the table:

name field2
------ -----
bob x
joe
john NULL

Thanks
Bart

 >> Stay informed about: How can i get all names where field2 is not equal to 'x' 
Back to top
Login to vote
Russell Fields

External


Since: Feb 21, 2007
Posts: 457



(Msg. 2) Posted: Tue Feb 12, 2008 9:07 am
Post subject: Re: How can i get all names where field2 is not equal to 'x' [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Bart,

I am afraid that you have to care about NULLs, since they don't compare as
equal or unequal. So...

-- Test for the NULL explicitly
select name from mytable where not (field2='x') or field2 IS NULL

-- Turn the NULL into a zero length character string that can be compared to
a string
select name from mytable where COALESCE(field2,'') <> 'x'

RLF

"Bart" wrote in message

> Hi,
>
> How can i get all names where field2 is not equal to 'x'?
>
> I did this: select name from mytable where not (field2='x')
>
> result: only joe is fetched
>
> this is the table:
>
> name field2
> ------ -----
> bob x
> joe
> john NULL
>
> Thanks
> Bart
>

 >> Stay informed about: How can i get all names where field2 is not equal to 'x' 
Back to top
Login to vote
Bart

External


Since: Feb 02, 2008
Posts: 2



(Msg. 3) Posted: Tue Feb 12, 2008 5:01 pm
Post subject: Re: How can i get all names where field2 is not equal to 'x' [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thanks

"Russell Fields" schreef in bericht

> Bart,
>
> I am afraid that you have to care about NULLs, since they don't compare as
> equal or unequal. So...
>
> -- Test for the NULL explicitly
> select name from mytable where not (field2='x') or field2 IS NULL
>
> -- Turn the NULL into a zero length character string that can be compared
> to a string
> select name from mytable where COALESCE(field2,'') <> 'x'
>
> RLF
>
> "Bart" wrote in message
>
>> Hi,
>>
>> How can i get all names where field2 is not equal to 'x'?
>>
>> I did this: select name from mytable where not (field2='x')
>>
>> result: only joe is fetched
>>
>> this is the table:
>>
>> name field2
>> ------ -----
>> bob x
>> joe
>> john NULL
>>
>> Thanks
>> Bart
>>
>
>
 >> Stay informed about: How can i get all names where field2 is not equal to 'x' 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Errors connecting from an x64 machine - Hi all; I've been doing battle w/Server2003 x64 and Sharepoint Services. Brand new server install, member server in the domain. Got the IIS/Sharepoint issues straight by installing dotnet framework 1.1 and running the command telling it to use 32 bi...

ODBC Data Destination for SSIS - Guys, anyone was able to connect to external data source via pure ODBC from Integration Services? And I don't mean SQl Server or Oracle, but DB's like PostgreSql or MySql? I just don't see the option on the destination tab. I tried both Export..

How to start SQL server in MultiUser Mode? - Hai, I used sqlservr -m to start the server in single user mode , how to get to multi user mode. Thanks, V.Boomessh

Windows 2000 problem - Hello, I've got a problem connecting to SQL server 2000 using windows 2000. Where testing a database using msde2000 (access project as front end) on a network with +/-20 people. And use of the "great" tool DbaMgr2k We have added al the us...

Cannot attach .MDF file? - I get the following error trying to attach an .mdf file, the first line is contained in the windows title bar. I do NOT have the .LDF file. Will I be able to salvage this database? Microsoft SQL-DMO (ODBC SQLState:42000) Error 1813: Could not open new...
   Database Forums (Home) -> Connect All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]