使用php mysql中的关键字搜索多个表

时间:2013-05-01 08:41:20

标签: php mysql search keyword

SELECT * from vehicle_adv_details
        LEFT JOIN vehicle_description on vehicle_adv_details.id=vehicle_description.vehicleid
        LEFT JOIN vehicle_extras on vehicle_adv_details.id=vehicle_extras.vehicleid
        LEFT JOIN vehicle_technical_features on vehicle_adv_details.id=vehicle_technical_features.vehicleid
        LEFT JOIN vehicle_photo on vehicle_adv_details.id=vehicle_photo.vehicleid

                            ) UNIONALL

    (SELECT * FROM propertysale_adv_details
        LEFT JOIN propertysale_adv_description ON propertysale_adv_details.id = propertysale_adv_description.propertysalesid
        LEFT JOIN propertysale_adv_listeragent ON propertysale_adv_details.id = propertysale_adv_listeragent.propertysalesid
        LEFT JOIN propertysale_adv_listerowner ON propertysale_adv_details.id = propertysale_adv_listerowner.propertysalesid
        LEFT JOIN propertysale_adv_photos ON propertysale_adv_details.id = propertysale_adv_photos.propertysalesid

                            ) UNIONALL

    (SELECT * from propertyrent_adv_details 
        LEFT JOIN propertyrent_description on propertyrent_adv_details.id=propertyrent_description.propertyrentid
        LEFT JOIN propertyrent_landlord_details on propertyrent_adv_details.id=propertyrent_landlord_details.propertyrentid
        LEFT JOIN propertyrent_photo on propertyrent_adv_details.id=propertyrent_photo.propertyrentid
        WHERE advtitle LIKE '%villa%'
                            )                                                       

        WHERE advtitle LIKE '%villa%' OR kilometer LIKE '%villa%'
        OR price LIKE '%villa%' OR description LIKE '%villa%'

1 个答案:

答案 0 :(得分:0)

advtitle kilometer pricedescription列如何具有不同的类型和内容只是LIKE一个常量字符串villa

villa是你的适用条件的神奇字词吗?