Oracle使用須要注意的一些技巧

使用or時,Oracle會將or左右的語句視爲兩個分別查詢,以下方語句io

select * from T_JC_tools where jc_id='11024418' and eff_Station is null or eff_station='北京' and  jc_id='11024418' and delete_time is null;select

實際中會將前面和後面總體分割開im

select * from T_JC_tools where (jc_id='11024418' and eff_Station is null )or (eff_station='北京' and  jc_id='11024418' and delete_time is null);查詢

因此咱們須要在or查詢的條件先後加上()保證查詢的準確性tools

select * from T_JC_tools where jc_id='11024418' and (eff_Station is null or eff_station='北京') and  jc_id='11024418' and delete_time is null;time

相關文章
相關標籤/搜索