select query with NOT in it??

  • Hi ,

     

    I am running a query like this

    select * from tblOrders where orderDate > '2004-12-31' and FREE = '1'

     

    this bit runs fine but I want to add onto it to pick out which rows do not have a specific order code 'abc'

    I have tried adding :  and Order code NOT 'abc' but syntax is wrong can anyone assist.

     

    Can you add NOT to a select query to exclude certain rows ?

    If not, can you advise if this can be done and how?

     

    thanks

    paul

  • try using != or <>.

  • select * from tblOrders where orderDate > '2004-12-31' and FREE = '1' AND [Order code] 'ABC'

  • As an aside, I'd recommend using over != since is part of the SQL-92 standard, but != is not. Both operators provide equivalent functionality.

  • You can use NOT in queries, especially in connection with other keywords: IS NOT NULL, NOT EXISTS, NOT BETWEEN. But if you simply want to say "is not equal to", then use <>.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply