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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 searching using brackets

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-01-11 : 08:27:12
Steve writes "I am writing a searching routine for a website.

The user inputs several words in a text box, words such as 'a', 'the' etc are removed and the results are put in an array.

I then want to search 3 fields in a database, returning only those where all of the search terms are held in any of the three fields.

the query I wrote went something like this:

SELECT a,b,c,d FROM table WHERE (a LIKE%x% OR b LIKE%x% OR c LIKE%x% ) AND (a LIKE%y% OR b LIKE%y% OR c LIKE%y%)

where a,b&c are the fields I am searching in and x&y are the search words.

This didn't work- I can't use brackets in SQL in the same way I would in maths, but nowhere can I find out how to do this search.

How do I perform this search?

Thanks in advance..."
   

- Advertisement -