lambdaQueryWrapper.inSql(AdminInspectionTaskBasicInfo::getJcdh, "select JCDH from ADMIN_INSPECTION_TASK_SIGNATURE_INFO WHERE SFZHM='" + userinfo.getIdCard() + "' AND JCDH IS NOT NULL GROUP BY JCDH"); 解读
时间: 2024-04-03 22:34:23 浏览: 123
这段代码是使用Mybatis-Plus框架中的LambdaQueryWrapper类来构建查询条件,查询的表名是AdminInspectionTaskBasicInfo,查询条件是AdminInspectionTaskBasicInfo中的Jcdh字段在一个子查询的结果集中。子查询的SQL语句是"select JCDH from ADMIN_INSPECTION_TASK_SIGNATURE_INFO WHERE SFZHM='" + userinfo.getIdCard() + "' AND JCDH IS NOT NULL GROUP BY JCDH",是查询ADMIN_INSPECTION_TASK_SIGNATURE_INFO表中SFZHM字段等于userinfo中的身份证号码并且JCDH字段不为空的记录,然后按JCDH字段进行分组,返回JCDH字段的结果集。这个结果集会被作为in语句的参数,用于查询AdminInspectionTaskBasicInfo表中Jcdh字段在这个结果集中的记录。
相关问题
FROM zdrgk_zdrgj a inner join zdryk_bkgl b on a.zdrgj_xm = b.bkgl_zdrxm and a.zdrgj_sfzhm = b.bkgl_sfz and b.del_flag = #{DEL_FLAG_NORMAL}增加一个条件,a.zdrgj_sbid在b.bkgl_bkqy的字符串中有出现过
好的,您希望我为您生成的SQL语句是这样的:
```SQL
SELECT *
FROM zdrgk_zdrgj a
INNER JOIN zdryk_bkgl b ON a.zdrgj_xm = b.bkgl_zdrxm
AND a.zdrgj_sfzhm = b.bkgl_sfz
AND a.zdrgj_sbid LIKE CONCAT('%', b.bkgl_bkqy, '%')
WHERE b.del_flag = #{DEL_FLAG_NORMAL}
```
这条SQL语句使用了 INNER JOIN 连接 zdrgk_zdrgj 表和 zdryk_bkgl 表,并且增加了一个条件 a.zdrgj_sbid 在 b.bkgl_bkqy 的字符串中有出现过,同时保留了原本的条件 b.del_flag = #{DEL_FLAG_NORMAL}。
<select id="findList" resultType="ZdrgkBkyj" > SELECT <include refid="zdrgkBkyjColumns"/> FROM zdrgk_zdrgj a left join zdryk_bkgl b on a.zdrgj_xm = b.bkgl_zdrxm and b.del_flag = #{DEL_FLAG_NORMAL} <where> a.del_flag = #{DEL_FLAG_NORMAL} ${dataScope} <if test="zdrgjXm != null and zdrgjXm != ''"> AND a.zdrgj_xm = #{zdrgjXm} </if> <if test="zdrgjSfzhm != null and zdrgjSfzhm != ''"> AND a.zdrgj_sfzhm = #{zdrgjSfzhm} </if> <if test="zdrgjXsd != null and zdrgjXsd != ''"> AND a.zdrgj_xsd = #{zdrgjXsd} </if> <if test="bkglZdrxm != null and bkglZdrxm != ''"> AND b.bkgl_zdrxm = #{bkglZdrxm} </if> </where> <choose> <when test="page !=null and page.orderBy != null and page.orderBy != ''"> ORDER BY ${page.orderBy} </when> <otherwise> ORDER BY a.update_date DESC </otherwise> </choose> </select>为zdrgkbkyj的xml文件 bkglZdrxm只作为查询没有显示在列表数据中如何在jeeplus中 queryParams : function(params) { var searchParam = $("#searchForm").serializeJSON(); searchParam.zdrgjXm = $("#zdrgjXm").val(); searchParam.bkglZdrxm = $("#bkglZdrxm").val(); if (searchParam.zdrgjXm && searchParam.bkglZdrxm && searchParam.zdrgjXm === searchParam.bkglZdrxm) { searchParam.matchedValue = searchParam.zdrgjXm; } else { searchParam.matchedValue = null; } searchParam.pageNo = params.limit === undefined? "1" :params.offset/params.limit+1; searchParam.pageSize = params.limit === undefined? -1 : params.limit; if(params.sort && params.order){ searchParam.orderBy = params.sort+ " "+ params.order; } return searchParam; }中添加一个查询条件 当前的zdrgjXm字段要和bkglZdrxm字段有一样的值才能显示
你想要在Jeeplus中添加一个查询条件,使得只有当zdrgjXm字段与bkglZdrxm字段具有相同的值时,该记录才能被显示。那么你可以在queryParams函数中添加以下代码:
```javascript
if (searchParam.zdrgjXm && searchParam.bkglZdrxm && searchParam.zdrgjXm === searchParam.bkglZdrxm) {
searchParam.matchedValue = searchParam.zdrgjXm;
} else {
searchParam.matchedValue = null;
}
```
这段代码会判断zdrgjXm和bkglZdrxm是否都有值,如果都有值且相同,则将matchedValue设为zdrgjXm的值,否则将matchedValue设为null。接着你可以在你的SQL语句中使用matchedValue来作为查询条件,例如:
```xml
<if test="matchedValue != null">
AND (a.zdrgj_xm = #{matchedValue} OR b.bkgl_zdrxm = #{matchedValue})
</if>
```
这段代码将检查是否存在matchedValue,如果有,则将其作为查询条件,匹配a表中的zdrgj_xm或b表中的bkgl_zdrxm。这样一来,只有当zdrgjXm和bkglZdrxm的值相同时,才能匹配到该记录。
阅读全文