Every derived table must have its own alias ——异常

来源:互联网 发布:linux 查找匹配字符串 编辑:程序博客网 时间:2024/05/21 10:53

今天在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语句的时候检查一下就可以避免的!给大家一个小小的参考了!

原创粉丝点击