Tony Pearce
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...
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thats it, thank you all very much, changed to an exact = and no wildcards and all is fine in the world..
ASKER
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....