select * from (SELECT b.id, b.project_id, p.NAME 'project_name', b.NAME, b.type, b.dept_id, d.dept_name, b.floor, b.useto, b.city, b.area, b.address, b.STATUS, b.del_flag, b.create_by, b.create_time, b.update_by, b.update_time FROM ledger_building b LEFT JOIN sys_dept d ON b.dept_id = d.dept_id LEFT JOIN ledger_project p ON b.project_id = p.id) tt
<where>
<iftest="projectId != null "> and project_id = #{projectId}</if>
<iftest="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<iftest="type != null and type != ''"> and type = #{type}</if>
<iftest="deptId != null "> and dept_id = #{deptId}</if>
<iftest="floor != null and floor != ''"> and floor = #{floor}</if>
<iftest="useto != null and useto != ''"> and useto = #{useto}</if>
<iftest="city != null and city != ''"> and city = #{city}</if>
<iftest="area != null "> and area = #{area}</if>
<iftest="address != null and address != ''"> and address = #{address}</if>
<iftest="status != null and status != ''"> and status = #{status}</if>
and del_flag = '0'
<iftest="projectName != null "> and project_name like concat('%', #{projectName}, '%') </if>
<iftest="name != null and name != ''"> and tt.name like concat('%', #{name}, '%')</if>
<iftest="type != null and type != ''"> and tt.type = #{type}</if>
<iftest="deptId != null "> and tt.dept_name like concat('%', #{deptName}, '%')</if>
<iftest="floor != null and floor != ''"> and tt.floor = #{floor}</if>
<iftest="useto != null and useto != ''"> and tt.useto = #{useto}</if>
<iftest="city != null and city != ''"> and tt.city = #{city}</if>
<iftest="area != null "> and tt.area = #{area}</if>
<iftest="address != null and address != ''"> and tt.address = #{address}</if>
<iftest="status != null and status != ''"> and tt.status = #{status}</if>
select * from (SELECT r.id, r.floor_id, f.name 'floor_name', r.NAME, r.number, r.area, r.STATUS, r.del_flag, r.create_by, r.create_time, r.update_by, r.update_time FROM ledger_room r LEFT JOIN ledger_floor f on r.floor_id=f.id) tt
<where>
<iftest="floorId != null "> and tt.floor_id = #{floorId}</if>
<iftest="floorName != null "> and tt.floor_name like concat('%', #{floorName}, '%')</if>
<iftest="name != null and name != ''"> and tt.name like concat('%', #{name}, '%')</if>
<iftest="number != null and number != ''"> and tt.number = #{number}</if>
<iftest="area != null "> and tt.area = #{area}</if>
<iftest="status != null and status != ''"> and tt.status = #{status}</if>