[thelist] SQL help

Joshua Olson joshua at alphashop.net
Thu Sep 27 13:05:30 CDT 2001


Uh, try adding some parethesis to provide order of precedence:

<snip>
SELECT * FROM Shop WHERE Active <> "0" AND (CompanyName LIKE "%what%" OR
Brief_Desc LIKE "%what%" OR City LIKE "%what%" OR  State LIKE "%what%"
CompanyName LIKE "%ever%" OR Brief_Desc LIKE "%ever%" OR City LIKE "%ever%"
OR State LIKE "%ever%") ORDER BY State ASC
</snip>

I added the left parenthesis before "CompanyName" and the right parenthesis
after "State LIKE '%ever%'"

Of course, you could do something like the following as an alternative:

SELECT * FROM Shop WHERE Active <> "0"
AND
  (CompanyName + Brief_Desc + City + State LIKE "%what%" OR
   CompanyName + Brief_Desc + City + State LIKE "%ever%")
ORDER BY State ASC

HTH,
-joshua

----- Original Message -----
From: "Roee Rubin" <webdesign1 at irubin.com>
To: "Thelist" <thelist at lists.evolt.org>
Sent: Thursday, September 27, 2001 2:01 PM
Subject: [thelist] SQL help


: Hello,
:
: I am having some problems generating a SQL statement (SQL has never been
my
: strong point).

<snip>
: I would like to perform a keyword search so that when a user searches for
: the phrase 'what ever' the CompanyName, City, State and Brief_Desc fields
: would be searched for a match. The results will only be displayed if the
: Active value IS NOT 0.
</snip>





More information about the thelist mailing list