一个搜索框可搜索具有上下级关系的任意一个关键字进行搜索

说明:module 模块表里面存在bank_id、project_id,搜索框可通过模块名、项目名和银行名搜索。三者之间的关系是银行包含项目、项目包含模块。

SELECT m.* FROM module m  
 	where
    m.name LIKE concat('%',#{keyWord, jdbcType=VARCHAR},'%')
    or m.bank_id in (select id from bank where bank_name like concat('%',#{keyWord, jdbcType=VARCHAR},'%'))
    or m.project_id in (select id from project where name like concat('%',#{keyWord, jdbcType=VARCHAR},'%'))
发布了55 篇原创文章 · 获赞 4 · 访问量 3149

猜你喜欢

转载自blog.csdn.net/qq_41347385/article/details/103483210
今日推荐