I'm trying to search through 3 different tables however it doesn't seem to be working. I have to remove username from the users table and then it works. How can I search different columns in each table?
$query = "(SELECT name, 'talent' FROM talent WHERE name LIKE '%" . $q ."%')
UNION ALL
(SELECT name, username, 'users' FROM users WHERE name LIKE '%" . $q ."%')
UNION ALL
(SELECT name, 'venues' FROM venues WHERE name LIKE '%" . $q ."%')";
UNIONed subquery must return exactly the same number of columns. Every corresponding column must be of compatible type as well.