Link to home
Start Free TrialLog in
Avatar of Tony Pearce
Tony PearceFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Mysql Use two AND's to retrieve only records matching both

Hi,
I have a query that looks for matching criteria in two columns, when using this query either/or gets selected, I need it to only pick the records that match both??

SELECT ProdCAT1 FROM $tableName WHERE ProdCAT1 LIKE '%$siteword%' AND ProdSELECT LIKE '%$brandword%'

Any pointers? I can't use PHP, it must be done in the query...
SOLUTION
Avatar of Sean Stuber
Sean Stuber

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tony Pearce

ASKER

Sorry, I typed question too quickly, what I mean is:

both conditions MUST be correct for the record to be returned, if either one is incorrect then it is not.

Or have I just got it totally wrong,

The query as is will return results even if second one does not....
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thats it, thank you all very much, changed to an exact = and no wildcards and all is fine in the world..