试试这个它会工作:
$q = "SELECT keyword, col, city_name, image_name, tutor_code
FROM (
SELECT tutor_name AS keyword, 'Tutors' AS col, IFNULL(c1.city_name, '') city_name, IFNULL(ti.image_name, '') image_name, tutor_code FROM tutors AS t
LEFT JOIN address a ON t.address_id = a.address_id
LEFT JOIN city c1 ON a.city_id = c1.city_id
LEFT JOIN tutor_images ti ON t.tutor_id = ti.tutor_id and ti.image_type = 'profile'
UNION
SELECT subjects AS keyword, 'Subject' AS col, '' city_name, '' image_name, '' tutor_code FROM subject
UNION
SELECT city_name AS keyword, 'City' AS col, '' city_name, '' image_name, '' tutor_code FROM city
UNION
SELECT institute_name AS keyword, 'Institute' AS col, '' city_name, '' image_name, '' tutor_code FROM institutes
) s
WHERE keyword LIKE '%$queryString%'
LIMIT 10";