%like% query
Hi,
I am trying to use a MySQL query to show results using a %like% statement and also specify one field is equal to 'yes', here is my query:
--------
SELECT * FROM item WHERE itemDesc like '%searchterm%' or itemName like '%searchterm%'
--------
This works fine except I want to only show item where avail(ability) is equal to yes, this works:
--------
SELECT *
FROM item
WHERE itemDesc like '%varsearch%' AND avail = 'yes'
---------
but when I try and search both columns it just does the query and ignores the 'avail=yes'?
This is essentially what I want to achieve:
-------------
SELECT *
FROM item
WHERE itemDesc like '%searchterm%' or itemName like '%searchterm%' AND avail = 'yes'
-------------
I have tried lot of ways but think I am approaching this wrong, please can you help,
Many thanks
David
|