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
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.ground_floor,b.underground_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="projectName != null "> and tt.project_name like concat('%', #{projectName}, '%') </if>
<iftest="projectId != null "> and tt.project_id = #{projectId} </if>