mysql多条件匹配模糊查询

  // mysql版 
select * from nf_massif where
        concat(IFNULL(id,''),
        IFNULL(plot_number,''),
        IFNULL(respective_region,''),
        IFNULL(land_name,''),
        IFNULL(land_area,''),
        IFNULL(geographic_coordinates,''),
        IFNULL(land_type,''),
        IFNULL(land_price,''),
        IFNULL(land_condition,''),
        IFNULL(suitable_crop,''),
        IFNULL(lease_term,''),
        IFNULL(tenant,''),
        IFNULL(create_time,''),
        IFNULL(update_time,''))

        like CONCAT ('%吉阳%','%实验室%')

//mybatis版

  select * from nf_massif where
        concat(IFNULL(id,''),
        IFNULL(plot_number,''),
        IFNULL(respective_region,''),
        IFNULL(land_name,''),
        IFNULL(land_area,''),
        IFNULL(geographic_coordinates,''),
        IFNULL(land_type,''),
        IFNULL(land_price,''),
        IFNULL(land_condition,''),
        IFNULL(suitable_crop,''),
        IFNULL(lease_term,''),
        IFNULL(tenant,''),
        IFNULL(create_time,''),
        IFNULL(update_time,''))
        like CONCAT ('%', #{content},'%','%', #{hotZone},'%')

//注意:多条件时,范围大的条件放在前面,范围小的条件放在范围大的条件的后面,一旦颠倒,范围大的条件将不起作用

 

你可能感兴趣的:(mysql,Mybatis)