left join 去重
sql如下:
SELECT A .guid, A .bidSectionCode, A .bidSectionName, A .changeContent, A .fabuTime, A .jyptId, A .changeTitle, A .isDeleted, A .createTime, T .TenderProjectType FROM ChangeNotice A left JOIN TenderProject T ON SUBSTR(A .bidSectionCode, 0, 20) = T .TENDERPROJECTCODE WHERE A .isDeleted = 0
其中 ChangeNotice 表与 TenderProject 表为多对一关系,但是页面要求展示ChangeNotice 的信息,所以只能这么写
但是查询出的数据有重复的,如下图:
解决办法如下:
SELECT DISTINCT A .guid, A .bidSectionCode, A .bidSectionName, # A .changeContent, A .fabuTime, A .jyptId, A .changeTitle, A .isDeleted, A .createTime, T .TenderProjectType FROM ChangeNotice A left JOIN TenderProject T ON SUBSTR(A .bidSectionCode, 0, 20) = T .TENDERPROJECTCODE WHERE A .isDeleted = 0
注意:A .changeContent为clob字段,distinct不允许有clob字段,否则会报:[Err] ORA-00932: inconsistent datatypes: expected - got CLOB
所以注释掉即可