今天在mysql 裏面寫了一個小例子,一個不小心爆了這小異常。
異常圖:
我的sql語句:
select count(*) from( select a.*, case when a.status='00' then '未提交' when a.status='01' then '待入庫' when a.status='02' then '已入庫' else '未知' end as status_msg,
case when a.pay_status='00' then '未通知' when a.status='01' then '已通知' when a.status='02' then '已付款' else '未知' end as status_msg,
(select proj_no from proj where id = a.proj_id) proj_no,
(select proj_name from proj where id = a.proj_id) proj_name,
(select custom_name from cust_custom_info where id = a.supplier_id ) supplier_name
from cooperation_order as a )
呵呵,這裏同樣的case then 的地方出錯了,就是在第二個地方有問題,把 case when a.pay_status='00' then '未通知‘ 的status都改爲 a.pay_status 還有後面的status_msg,改一個名字就好了!這樣的小異常,寫sql語句的時候檢查一下就可以避免的!給大家一個小小的參考了!