mysql 查询奇偶数


1、特殊字符处理

  1.1 奇数 &1

select
   bi.file_type   FILE_TYPE,
   bi.file_batchid   FILE_BATCHID,
   bi.file_path   FILE_PATH,
   conf.save_servercode  SAVE_SERVERCODE,
   bi.execution_order   EXECUTION_ORDER
from
  tbentrymanage_bi  bi
left join tbentrymanage_conf  conf  on  (bi.file_type = conf.file_type  and  bi.systemstatus = conf.systemstatus)
where
     bi.save_status = '0'
and  bi.systemstatus = '1'
and  bi.execution_order&1   ##字段&1 查询数据大于等于1的奇数。字段execution_order=(execution_order>>1)<<1 ; 查询数据大于等于2的偶数。 xml中&转义两种形式:1)& 2)<![CDATA[&]]>
order by file_type , execution_order

执行结果:

 2)偶数  字段=(字段>>1)<<1

 2、mod 取余方法

  2.1 奇数 mod 2 = 1

  2.1 偶数 mod 2 = 0

 


免责声明!

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



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