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



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" <b@xxx> wrote in message
news:%23oX$8XVbIHA.4712@xxxxxxxxxxxxxxxxxxxxxxx
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



.



Relevant Pages

  • Re: How can i get all names where field2 is not equal to x
    ... I am afraid that you have to care about NULLs, since they don't compare as ... -- Turn the NULL into a zero length character string that can be compared ... How can i get all names where field2 is not equal to 'x'? ... result: only joe is fetched ...
    (microsoft.public.sqlserver.connect)
  • Re: How does ATTACH pass address of ECB to child?
    ... "compare and swap" simply means that. ... It compares field1 against field2. ... For IBM-MAIN subscribe / signoff / archive access instructions, ...
    (bit.listserv.ibm-main)
  • Re: OT:Way to go Al
    ... closely at what she is saying and proposing, and then compare and ... contrast this with her Democratic competitors. ... Joe - Registered Linux User #449481 ...
    (alt.smokers.cigars)
  • RE: Compare Rows and delete duplicate records
    ... Taking the example again for my data for Joe. ... Compare A2 with A1 If Not Equal then Do nothing ... Else if equals ... Once Row2 is completely comapred and added to row1, ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Comparing two DataSets with a Merge
    ... > been changed over time offsite and saved in an access database. ... > take advantage of versions in the dataset to compare previous and current ... >> Joe, ... >> The tables that has to be merged needs the same primary key at least and ...
    (microsoft.public.dotnet.framework.adonet)

Loading