Guest Posted July 15, 2008 Share Posted July 15, 2008 What's wrong with my query here? $searchQuery = "(SELECT title, content FROM pages WHERE title LIKE '%$searchString%' OR content LIKE '%$searchString%') UNION ALL (SELECT title FROM albums WHERE title LIKE '%$searchString%') UNION ALL (SELECT title FROM blogs WHERE title LIKE '%$searchString%') UNION ALL (SELECT title, content FROM posts WHERE title LIKE '%$searchString%' OR content LIKE '%$searchString%') UNION ALL (SELECT title, content FROM comments WHERE title LIKE '%$searchString%' OR content LIKE '%$searchString%') UNION ALL (SELECT title, content FROM events WHERE title LIKE '%$searchString%' OR content LIKE '%$searchString%')"; I keep getting an invalid query error :\ Link to comment https://forums.phpfreaks.com/topic/114778-solved-mysql-union-error/ Share on other sites More sharing options...
maxhugen Posted July 15, 2008 Share Posted July 15, 2008 Each select in the union must return the same number of fields. The first select returns 2 fields, the next only 1. Link to comment https://forums.phpfreaks.com/topic/114778-solved-mysql-union-error/#findComment-590158 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.