Mysql:This version of MySQL doesn’t yet support ‘LIMIT & IN/ALL/ANY/SOME 错误解决

本文涉及的产品
云数据库 RDS MySQL,集群版 2核4GB 100GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介: This version of MySQL doesn’t yet support ‘LIMIT & IN/ALL/ANY/SOME 错误解决这次国庆节回来后的测试中,在一个Mysql表达式中使用嵌套查询,出现了这个错误。
This version of MySQL doesn’t yet support ‘LIMIT & IN/ALL/ANY/SOME 错误解决

这次国庆节回来后的测试中,在一个Mysql表达式中使用嵌套查询,出现了这个错误。原因是内层select语句带有limit子句。

在网上查了下,有文章指出:
比如这样的语句是不能正确执行的。
select * from table where id in (select id from table limit 12);

但是,只要你再加一层就行。如:
select * from table where id in (select t.id from (select * from table limit 12)as t)

这样就可以绕开limit子查询的问题。
问题解决。
后来我发现,上述是解决问题的一个方法,其实还有一个更好的做法,就是把限制条件放到from而非where子句中,就不必出现嵌套再嵌套。
如上例,可以改为:
select * from (select id from table limit 12) as foo;
注意:其实as foo特别重要,如果不写成from () as xxx的形式,即不给from后的select语句构成表名,那么最后系统仍会报错。
相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
5天前
|
SQL 关系型数据库 MySQL
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
|
4天前
|
SQL 存储 关系型数据库
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
|
2月前
|
SQL 数据采集 关系型数据库
如何解决MySQL报错 You have an error in your SQL syntax; check the manual that corresponds to your MySQL?
如何解决MySQL报错 You have an error in your SQL syntax; check the manual that corresponds to your MySQL?
|
11月前
|
SQL 关系型数据库 MySQL
check the manual that corresponds to your MySQL server version for the right syntax to use near lin
注意这种一般情况下是语法问题,说明mysql的各种语句还是不够熟练, (1)看表名是不是使用了Mysql的关键字,如果是,请立马改掉; (2)语句给出哪里错误,如我的题目中给出“near”,说明在那附近有问题。 (3)检查mybatis中mapper里sql语句占位符是否写对,我的问题是将#{name}写成了#(name),尴尬。
142 0
|
关系型数据库 MySQL
Error:Unable to find a match: mysql-community-server
Error:Unable to find a match: mysql-community-server
187 0
|
SQL 关系型数据库 MySQL
check the manual that corresponds to your MySQL server version for the right syntax to use near
check the manual that corresponds to your MySQL server version for the right syntax to use near
863 0
check the manual that corresponds to your MySQL server version for the right syntax to use near
|
关系型数据库 MySQL
【Mysql】Ignoring query to other database解决方法
【Mysql】Ignoring query to other database解决方法
145 0
【Mysql】Ignoring query to other database解决方法
|
关系型数据库 MySQL
check the manual that corresponds to your MySQL server version for the right syntax to use near '...
背景交代 折扣价格设置的是负数,框架用的TP5。 活动规则:当活动开始时候销售价格加上折扣价格(相当于减折扣价格)就是活动价格,当活动结束时候,减去折扣价格(负负得正)就恢复原价。
6917 0
|
关系型数据库 MySQL C语言
MySQL 启动报错Table 'mysql.plugin' doesn't exis(转载)
安装完成后,按照网上说启动mysql时却报了以下错误: [root@localhost bin]# ./mysqld 2015-10-23 16:54:55 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated.
1362 0