this is your query (formatted for readability) --
Code:
SELECT *
FROM table
WHERE name = 'Horseracing'
AND DESCRIPTION LIKE '%tips%'
OR TITLE LIKE '%tips%'
the problem you are having is the precedence of ANDs over ORs
your query is actually evaluated as though it had parentheses like this --
Code:
SELECT *
FROM table
WHERE (
name = 'Horseracing'
AND DESCRIPTION LIKE '%tips%'
)
OR TITLE LIKE '%tips%'
what you probably wanted was the following --
Code:
SELECT *
FROM table
WHERE name = 'Horseracing'
AND (
DESCRIPTION LIKE '%tips%'
OR TITLE LIKE '%tips%'
)
see the difference?
when mixing ANDs and ORs, always code your own parentheses to control the evaluation sequence
Bookmarks