sql 实现 动态条件查询


SELECT
   *
FROM
    ZHC_VSL_DEV_ENCODER_CHN chn LEFT JOIN
    ZHC_VSL_DEV_ENCODER_DEV dev ON  chn.DEVICECODE = dev.DEVICEID
WHERE
    1 = 1 
    AND (
    (${device_type}='1' and dev.category='1') or 
    (${device_type}='2' and dev.category='5' AND ( instr(','||chn.cameraFunctions||',',',8,')>0 or instr(','||chn.cameraFunctions||',',',12,')>0 or instr(','||chn.cameraFunctions||',',',10,')>0)) or 
    (${device_type}='3' and chn.device_type='3') or
    (${device_type}='4' and dev.category='5' AND (instr(','||chn.cameraFunctions||',',',9,')>0 or instr(','||chn.cameraFunctions||',',',10,')>0))
    )
${device_type} 为条件值,不同的${device_type},查询条件不同。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM