Solved

SQL - search multiple strings

Posted on 2008-06-11
3
1,081 Views
Last Modified: 2012-06-21
Hi Experts

I'm having some difficulty adding strings to an existing, functioning query.  It should read  where PP_Problem contains string1 or string 2 but i get syntax errors whichever way i try this.

PS using the word OR instead of a comma returns all the records without filtering any of the strings

Many thanks

Peter


this works 

SQL = SQL & " where [PP_Problem] like '*String1*' "
 

this one doesn't 

SQL = SQL & " where [PP_Problem] like '*String1*' , '*String2*'"

Open in new window

0
Comment
Question by:peterdarazs
3 Comments
 
LVL 4

Accepted Solution

by:
msfletch earned 65 total points
Comment Utility
Try this:

SQL = SQL & " where [PP_Problem] like '*String1*' OR [PP_Problem] like '*String2*'"
0
 
LVL 2

Assisted Solution

by:jml948
jml948 earned 60 total points
Comment Utility
I believe the correct way to do this would be the following:

SQL = SQL & " where [PP_Problem] like '*String1*' or [PP_Problem] like '*String2*'"
0
 

Author Closing Comment

by:peterdarazs
Comment Utility
Thanks experts

Sorry about the points split - there were 2 identical responses and I now wish i assigned more to go around. many thanks
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now