• mysql之instr函数


    1.用于模糊查询,做为过滤条件

    ---------------------------上级的新闻下级可以看到-------------------------
    SELECT a.pk_cms_nrgl_st AS pk_id, a.time_stamp AS time_stamp, b.xalljgmc AS xalljgmc, a.cbt AS cbt, a.fk_cms_lmgl AS fk_cms_lmgl, a.cfbsj AS cfbsj, a.czt AS czt, a.cbody AS cbody, a.sys_xzqh AS sys_xzqh, a.sys_djzt AS sys_djzt, a.sys_djztms AS sys_djztms, a.sys_spzt AS sys_spzt, a.sys_spzt AS sys_spztmc, a.sys_spztms AS sys_spztms, a.sys_shrid AS sys_shrid, a.sys_shr AS sys_shr, a.sys_shrq AS sys_shrq, a.sys_xgrid AS sys_xgrid, a.sys_xgr AS sys_xgr, a.sys_xgrq AS sys_xgrq, a.sys_zdrid AS sys_zdrid, a.sys_zdr AS sys_zdr, a.sys_zdrq AS sys_zdrq FROM cms_nrgl_st a, mz_xzjg b WHERE a.sys_xzqh=b.xzqh_id AND a.sys_scbj = '0' AND INSTR('330101', b.node_id) > 0 AND a.sys_spzt = 1 ORDER BY time_stamp desc, cfbsj desc limit 0, 20

    配置

    <where name="user.xnode"  code="b.node_id"  datatype="string" attribute="true" scope="session" opersign="instrcode" link="AND" />

    2.以下代码等同上面的,用了concat做拼接

    SELECT a.pk_cms_nrgl_st AS pk_id, a.time_stamp AS time_stamp, b.xalljgmc AS xalljgmc, a.cbt AS cbt, a.fk_cms_lmgl AS fk_cms_lmgl, a.cfbsj AS cfbsj, a.czt AS czt, a.cbody AS cbody, a.sys_xzqh AS sys_xzqh, a.sys_djzt AS sys_djzt, a.sys_djztms AS sys_djztms, a.sys_spzt AS sys_spzt, a.sys_spzt AS sys_spztmc, a.sys_spztms AS sys_spztms, a.sys_shrid AS sys_shrid, a.sys_shr AS sys_shr, a.sys_shrq AS sys_shrq, a.sys_xgrid AS sys_xgrid, a.sys_xgr AS sys_xgr, a.sys_xgrq AS sys_xgrq, a.sys_zdrid AS sys_zdrid, a.sys_zdr AS sys_zdr, a.sys_zdrq AS sys_zdrq FROM cms_nrgl_st a, mz_xzjg b WHERE a.sys_xzqh=b.xzqh_id AND a.sys_scbj = '0' and a.sys_spzt = 1
    AND '33' LIKE concat(b.node_id,'%') ORDER BY time_stamp desc, cfbsj desc limit 0, 20

  • 相关阅读:
    基于项目中遇到的技术问题,谈谈SharedPreferences的使用的注意问题
    mongodb数据库从库同步主库维护js脚本
    MongoDB数据库日志备份压缩脚本
    mongodb数据库磁盘碎片整理。
    mongodb表字段处理生成域名字段
    根据当前进程号,获取进程下线程数目
    mongodb mapreduce示例
    MongoDB数据库库级锁研究分析
    mongodb库表信息监控脚本
    利用JAVA设计一个可视化日历
  • 原文地址:https://www.cnblogs.com/tongcc/p/11357293.html
Copyright © 2020-2023  润新知