MySql 1248 - Every derived table must have its own alias
执行一个sql语句,报错:1248 - Every derived table must have its own alias
提示说每一个衍生出来的表,必须要有自己的别名
执行子查询的时候,外层查询会将内层的查询当做一张表来处理,所以我们需要给内层的查询加上别名
错误的:
select count(*)
from(
select
FROM_UNIXTIME(`user_task`.`CREATE_TIMESTAMP`, "%Y-%m-%d")
FROM
r_user_task `user_task`
LEFT JOIN
e_task `task` ON `user_task`.`TASK_ID` = `task`.`ID`
where `user_task`.`COMPLETE_STATUS` = "" and `user_task`.`user_id` =
group by FROM_UNIXTIME(`user_task`.`CREATE_TIMESTAMP`, "%Y-%m-%d")
)
正确的sql,应该加上别名,如下:
select count(*)
from(
select
FROM_UNIXTIME(`user_task`.`CREATE_TIMESTAMP`, "%Y-%m-%d")
FROM
r_user_task `user_task`
LEFT JOIN
e_task `task` ON `user_task`.`TASK_ID` = `task`.`ID`
where `user_task`.`COMPLETE_STATUS` = "" and `user_task`.`user_id` =
group by FROM_UNIXTIME(`user_task`.`CREATE_TIMESTAMP`, "%Y-%m-%d")
) as t
参考:
https://blog.csdn.net/cao478208248/article/details/28122113
MySql 1248 - Every derived table must have its own alias的更多相关文章
- 【mysql报错】[Err] 1248 - Every derived table must have its own alias
当我运行一条联合查询的sql语句时报如下错误: [Err] 1248 - Every derived table must have its own alias,大概意思是每一张派生表必须要有自己的别 ...
- [Err] 1248 - Every derived table must have its own alias
问题描述 [Err] 1248 - Every derived table must have its own alias 问题原因 这句话的意思是说每个派生出来的表都必须有一个自己的别名 我的Mys ...
- (转载)1248 - Every derived table must have its own alias
(转载)http://hi.baidu.com/lylegend13/item/a79f17eb51f5dff7e0a5d43b 1. select count(distinct CName) fro ...
- 错误代码: 1248 Every derived table must have its own alias
1.错误描述 1 queries executed, 0 success, 1 errors, 0 warnings 查询:SELECT stu_id, (SELECT stu_name FROM t ...
- MySQL错误:Every derived table must have its own alias
Every derived table must have its own alias 派生表都必须有自己的别名 一般在多表查询时,会出现此错误. 因为,进行嵌套查询的时候子查询出来的的结果是作为一个 ...
- mysql—mysql错误Every derived table must have its own alias解决
Every derived table must have its own alias 这句话的意思是说每个派生出来的表都必须有一个自己的别名. 一般在多表查询时,会出现此错误. 因为,进行嵌套查询的 ...
- mysql错误:“ Every derived table must have its own alias”(每个派生出来的表都必须有一个自己的别名)
自我感悟: 由此可以延伸,我们得到一个结果集,可以通过as XXX的方式,把结果集给当作一张表来用,以实现子查询: 一般在多表查询时,会出现此错误. 因为,进行嵌套查询的时候子查询出来的的结果是作为一 ...
- mysql出现错误“ Every derived table must have its own alias”
Every derived table must have its own alias 这句话的意思是说每个派生出来的表都必须有一个自己的别名 一般在多表查询时,会出现此错误. 因为,进行嵌套查询的时 ...
- 【MySQL】mysql出现错误“ Every derived table must have its own alias”
Every derived table must have its own alias 这句话的意思是说每个派生出来的表都必须有一个自己的别名 一般在多表查询时,会出现此错误. 因为,进行嵌套查询的时 ...
随机推荐
- 【SQL Server 学习系列】-- 随机生成日期时间的SQL脚本
DECLARE @dt1 DATETIME,@dt2 DATETIME,@a BIGINT,@b BIGINT SET @dt1='2010-01-01'--开始日期 SET @dt2='2010-0 ...
- sata express接口
华硕z97主板的sata express接口目前没什么用,但随着电脑接口的发展,可能会占据一席之地. 1.顾名思义,SATA-Express是SATA接口 + PCI-Express的混合体,其理论带 ...
- cache and database
This article referenced from http://coolshell.cn/articles/17416.html We all know that high concurren ...
- M2Crypto
M2Crypto = Python + OpenSSL + SWIG M2Crypto is a crypto and SSL toolkit for Python. 上面是M2Crypto的READ ...
- 优雅的在React项目中使用Redux
概念 首先我们会用到哪些框架和工具呢? React UI框架 Redux 状态管理工具,与React没有任何关系,其他UI框架也可以使用Redux react-redux React插件,作用:方便在 ...
- cnn,rnn,dnn
CNN(卷积神经网络).RNN(循环神经网络).DNN(深度神经网络)的内部网络结构有什么区别? https://www.zhihu.com/question/34681168 CNN(卷积神经网络) ...
- 用JAVA生成老电影海报
先看图,再讲原理.生成效果对照: 机器全自己主动生成.是不是非常酷炫?:) 数字图像,由无数个像素组成,通常情况下,每一个像素包括有RGB三个值,算法原理事实上非常easy: 一,遍历全部像素,将RG ...
- regulator_get 调用过程【转】
本文转载自:http://blog.csdn.net/u012719256/article/details/52083961 Touch panel DTS 分析(MSM8994平台,Atmel 芯片 ...
- 微软2016校园招聘在线笔试 [Recruitment]
时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 A company plans to recruit some new employees. There are N ca ...
- 【转】Material Design 折叠效果 Toolbar CollapsingToolbarLayout AppBarLayout
我非常喜欢Material Design里折叠工具栏的效果,bilibili Android客户端视频详情页就是采用的这种设计.这篇文章的第二部分我们就通过简单的模仿bilibili视频详情页的实现来 ...