我有2個select語句。如果選擇查詢返回空結果,請在mysql中運行另一個select查詢
1- select sm.id, IFNULL(sm.unit_price,0) as unit_price
from crm_stock_manager sm
left join crm_purchase_order_items poi on poi.id = sm.purchase_order_item_id and poi.is_del = 0
left join crm_products p on poi.product_id = p.id and p.is_del = 0
where sm.is_del = 0 and IFNULL(sm.unit_price, '') != '' and p.id = 253 order by sm.created_on;
2- select 0 as id ,price as unit_price from crm_products where id = 253 and is_del=0;
如果第一個select語句返回一個空結果,那麼我想運行第二個select語句。
請幫幫我。
只需執行2個獨立的查詢,陸續 – zerkms 2013-02-27 04:55:56
是否有任何可能的方式來做到這一點在MySQL? – 2013-02-27 05:01:17
是否有任何理由在mysql中這樣做? – zerkms 2013-02-27 05:05:09