mybatisplus多表查詢及自定義查詢


要查詢的mysql語句:

SELECT DISTINCT a.pool_name,a.equipment_name,a.commissioning_time from equipment a,sewage_pool b where a.pool_name=b.pool_name

1、添加VO類:EquipmentVO

上述查詢中有:pool_name、equipment_name、commission_time字段,因此新增類VO中添加相應屬性

@Data
public class EquipmentVO {
    private String poolName;
    private String equipmentName;
    private String commissioningTime;
}

2、在對應的mapper層接口EquipmentMapper添加注解與方法

@Select("SELECT DISTINCT a.pool_name,a.equipment_name,a.commissioning_time from equipment a,sewage_pool b where a.pool_name=b.pool_name ")
List<EquipmentVO> equipmentVO();

3、在service/Impl層中返回查詢給前端

public List<EquipmentVO> configurationBoard() {
        return mapper.equipmentVO();
    }

 

 
         
         
       


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM