Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select ...where item is not like ...syntax problem 1

Status
Not open for further replies.

RSX02

Programmer
May 15, 2003
467
CA
Hi
I'm trying to do a request that bring me all record that is not like specific values.

I don't want that the items that looks like "Hardware", "Installation", "Programming" be in my request.
Something like
Select * from TblItem where Item is not like "Installation" and not like "Hardware"...etc...
Could you help me with the Syntax please.
Thanks in advance
 
When you use [NOT] LIKE, you need a wildcard character because SQL is looking for something that contains whatever your input is.
Code:
Select * from TblItem where Item is not like "Installation%" and Item not like "Hardware%"
The "%" sign is the wildcard of choice for this expression. After your AND, you have to identify Item again for the next "Not Like".


Dan.
 
Select * from TblItem where (Item not like '%Installation%'
and Item not '%Hardware%') and (other filtering conditions not related to the not like clauses, if any)
 
So how can I transform this line?
Set RsItem = MyConn.Execute("select * from TblItem where ManufacturePartN is not like" & "Hardware%")

Thanks again
 
Set RsItem = MyConn.Execute("select * from TblItem where (ManufacturePartN not like '%HARDWARE%') and (ManufacturePartN not like '%INSTALLATION%')")

This is working
Thanks
 
Have you considered using NOT IN:

Select * from TblItem where Item NOT IN ('Installation', 'Hardware', 'Programming')

-SQLBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top