select cast(demand_id as char) demand_id,cast(if(demander_id is null,'',demander_id) as char) demander_id,cast(if(service_id is null,'',service_id) as char) service_id from ido_demand_single where (demander_id=15 and service_id=30) or (demander_id=30 and service_id=15) and cancel=0
select cast(demand_id as char) demand_id,cast(if(demander_id is null,'',demander_id) as char) demander_id,cast(if(service_id is null,'',service_id) as char) service_id from ido_demand_single where ((demander_id=15 and service_id=30) or (demander_id=30 and service_id=15) )and cancel=0
以上两个sql都可以在navicat中使用查询结果一致,但在jdbc拼sql的时候发生了查询错误,经过排查发现,在mysql的jar包中执行时候
and优先于or
但在navicat中执行,or和and是同级别的,谁在前边谁优先,所以可以看出不同的mysql驱动,执行的时候也会有细微的问题出现,在此记录一下