mysql查询count

 

Every derived table must have its own alias

每个派生出来的表都必须有一个自己的别名

一般在多表查询时,会出现此错误。

因为,进行嵌套查询的时候子查询出来的的结果是作为一个派生表来进行上一级的查询的,所以子查询的结果必须要有一个别名

把MySQL语句改成:select count(*) from (select * from ……) a;或者

select count(*) from (select * from ……) as a;

select count(*) from (select c.case_number, a.openaccount_id,c.status from
lassen_legal_case c ,
lassen_suit_entity e ,
lassen_account a
where c.is_deleted='n'
 and c.id=e.case_id
 and e.user_id=a.id
 and e.entity_role='accused'
  and a.id=136) a;

 

 

posted @ 2015-12-22 18:18  dieyaxianju  阅读(465)  评论(0编辑  收藏  举报