Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 HELP with LIKE statement

Author  Topic 

demifelix
Starting Member

22 Posts

Posted - 2007-11-09 : 12:32:59
Hi,

Can someone please help me how to write a proper LIKE statement to perform the search? I have a column with text descriptions of something lik this:

1. 'MICROPRINT COLOR COPY'
2. 'MICROPRINT INKJET'
3. 'MICROPRINT LASER'
4. 'MICROPRINT ABC'
5. 'MICROPRINT CDE'
6. 'MICROPRINT XYZ'
7. 'MICROPRINT 123'
8. 'MACROPRINT INKJET'
...

I'm trying to select all records that includes the words 'MICROPRINT' AND does not include the words 'COLOR COPY' OR 'INKJET'. In other words, I'm trying to get all 'MICROPRINT' records except 'MICROPRINT COLOR COPY' and 'MICROPRINT INKJET'.

Thanks for your help.

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-11-09 : 12:36:19
select * from YourTable
where YourColumn not like '%COLOR COPY%' and not like '%INKJET%'

note that this would be a lot easier with full text search if you have an option to install it

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-11-09 : 14:12:15
quote:
Originally posted by spirit1

select * from YourTable
where YourColumn not like '%COLOR COPY%' and YourColumn not like '%INKJET%'




Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-11-09 : 14:14:10
doh!

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-11-09 : 14:16:43
Where is the check for 'MicroPrint'?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-11-09 : 14:24:20
i leave that as the excercise for the OP.
can't let them have everything now can we

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2007-11-09 : 14:41:36
Scan Scan Scan



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

demifelix
Starting Member

22 Posts

Posted - 2007-11-10 : 20:50:57
Thanks everyone for your help, I got the idea.
Go to Top of Page
   

- Advertisement -