Why isn't this simple MySQL statement working?
- by Clark
I am trying to match a user inputted search term against two tables: posts and galleries. The problem is the union all clause isn't working. Is there something wrong with my code?
$query = mysql_query("
SELECT * FROM posts WHERE title LIKE '%$searchTerm%'
OR author LIKE '%$searchTerm%'
OR location LIKE '%$searchTerm%'
OR excerpt LIKE '%$searchTerm%'
OR content LIKE '%$searchTerm%'
UNION ALL
SELECT * FROM galleries WHERE title LIKE '%$searchTerm%'
");