Solved

SQL - search multiple strings

Posted on 2008-06-11
3
1,083 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
ID: 21766330
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
ID: 21766339
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
ID: 31466447
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
email about the whoisactive result 7 36
Need help on t-sql 2012 10 55
Dcount using a date in a table compared to today's date 3 31
TSQL query to generate xml 4 36
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

831 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