union 組合

查詢單據,卻不知道單據在當前表還是在歷史表

select * from wms_bill where ... union select * from wms_billhistory  where ...

 

 

或者

 

if exists(select * from wms_bill where ..) begin select * from wms_bill where ...  end else begin select * from wms_billhistory  where ... 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章