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的字符串中有出现过
时间: 2023-12-16 14:02:28 浏览: 44
好的,您希望我为您生成的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}。
相关问题
通过后台添加多表查询 <if test="bkglZdrxm != null and bkglZdrxm != ''"> AND b.bkgl_zdrxm = #{bkglZdrxm} </if> <if test="zdrgjXm != null and zdrgjXm != ''"> AND a.zdrgj_xm = #{zdrgjXm} </if> FROM zdrgk_zdrgj a left join zdryk_bkgl b on a.zdrgj_xm = b.bkgl_zdrxm and b.del_flag = #{DEL_FLAG_NORMAL}如何在jeeplus中的前端js中queryParams : function(params) { var searchParam = $("#searchForm").serializeJSON(); 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都有相同值的值
可以在前端的queryParams函数中添加以下代码:
```javascript
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;
}
```
这里假设页面中有两个输入框,id分别为zdrgjXm和bkglZdrxm,同时将匹配结果存储在matchedValue中。可以根据实际情况修改代码。
然后在后端的SQL语句中添加以下代码:
```sql
<if test="matchedValue != null">
AND a.zdrgj_xm = #{matchedValue}
AND b.bkgl_zdrxm = #{matchedValue}
</if>
```
这样就可以只查询zdrgjXm和bkglZdrxm都有相同值的数据了。
在jeeplus中假设我们的数据库中有两个表:zdrgk_bkgl和zdrgk_zdrgj,它们的字段如下: zdrgk_bkgl:id create_by create_date update_by update_date remarks del_flag bkgl_zdrxm bkgl_zdrylx bkgl_sfz bkgl_dh bkgl_zz bkgl_zzjd bkgl_zzwd bkgl_hjd bkgl_bkdj bkgl_bkyy bkgl_bkr bkgl_bkbm bkgl_bksj bkgl_cksj bkgl_ckr bkgl_ckbm bkgl_spr bkgl_spsj bkgl_spbm bkgl_spyj bkgl_bkzt bkgl_zp bkgl_bkqy bkgl_ckyy bkgl_spjg bz3 bz4 bz5 zdrgk_zdrgj:id create_by create_date update_by update_date remarks del_flag zdrgj_zdrid zdrgj_xm zdrgj_sfzhm zdrgj_xsd zdrgj_sbid zdrgj_zpzp zdrgj_zpsj bz1 bz2 bz3 bz4 bz5 bkyj_yjnr bkyj_czr bkyj_czbm bkyj_czsj bkyj_czzt bkyj_czqk bkyj_fj 在jeeplus中如何在zdrgkbkyj.xml中写一段SQL将zdrgkbkgl的bkgl_zdrxm和zdrgkzdrgj的zdrgj_xm一样时 把他显示在zdrgkbkyjlist表单中
您可以在zdrgkbkyj.xml中使用SQL查询语句,使用内连接(INNER JOIN)将zdrgk_bkgl表和zdrgk_zdrgj表连接起来,然后筛选出bkgl_zdrxm和zdrgj_xm相同的记录,并将其显示在zdrgkbkyjlist表单中。
具体的SQL语句如下:
```
<select id="findList" resultMap="BaseResultMap">
SELECT bkgl.id, bkgl.bkgl_zdrxm AS bkyj_czr, zdrgj.zdrgj_xm AS bkgl_zdrxm
FROM zdrgk_bkgl bkgl
INNER JOIN zdrgk_zdrgj zdrgj ON bkgl.bkgl_zdrxm = zdrgj.zdrgj_xm
WHERE bkgl.del_flag = '0' AND zdrgj.del_flag = '0'
</select>
```
这个SQL查询语句将会以bkgl_zdrxm和zdrgj_xm作为关键字连接zdrgk_bkgl和zdrgk_zdrgj表。在查询结果中,我们将会得到bkgl.id, bkgl.bkgl_zdrxm和zdrgj.zdrgj_xm三个字段的值。其中,bkgl.bkgl_zdrxm字段将会被作为操作人(bkyj_czr)显示在zdrgkbkyjlist表单中,而zdrgj.zdrgj_xm字段将会被作为bkgl_zdrxm显示在zdrgkbkyjlist表单中。
阅读全文