SELECT
products.products_code,
products.productstype_id
FROM
products
LEFT JOIN room_bedroom_price ON (
products.products_code = room_bedroom_price.products_code
)
LEFT JOIN golf_price ON (
products.products_code = golf_price.products_code
)
LEFT JOIN hotel ON (
products.products_code = hotel.products_code
)
LEFT JOIN resident ON (
products.products_code = resident.products_code
)
LEFT JOIN golf ON (
products.products_code = golf.products_code
)
WHERE
(
hotel.province_id LIKE '%%'
OR resident.province_id LIKE '%%'
OR golf.province_id LIKE '%%'
)
AND (
hotel.public = '1'
OR resident.public = '1'
OR golf.public = '1'
)
AND (
hotel.hotel_name_kr LIKE '%narai%'
OR hotel.hotel_name_en LIKE '%narai%'
OR resident.resident_name_kr LIKE '%narai%'
OR resident.resident_name_en LIKE '%narai%'
OR golf.golf_name_kr LIKE '%narai%'
OR golf.golf_name_en LIKE '%narai%'
)
GROUP BY
products.products_cod