社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  DATABASE

mysql语句中的语法错误代码:1064

user6167014 • 6 年前 • 2182 次点击  

我不明白为什么它会抛出异常,花了我很多时间。我非常感谢你的帮助。

这是mysql语句

 use dvdrental;

Select S.city From S OS
Where EXISTS (select top(1) S.city, 
 Count(S.s_num) From S In S
 Where In S.city = OS.city Group By S.city 
 Order by Count(S.s_num) DESC)

例外是

  Error Code: 1064. You have an error in 
 your SQL syntax; check the manual that 
 corresponds to your MySQL server version 
for the right syntax to use near '.city, 
Count(S.s_num) From S In S Where In S.city = OS.city Group By S.city Orde' at line 2

谢谢您

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/46953
文章 [ 1 ]  |  最新文章 6 年前
Vijunav Vastivch
Reply   •   1 楼
Vijunav Vastivch    7 年前

具体是因为:

mysql:没有 TOP 喜欢

select top(1)

你必须这样使用:

limit 1 

最后

这样地:

Select S.city From S OS Where EXISTS 
(select S.city, Count(S.s_num) From S In S Where In S.city = OS.city Group By S.city Order by Count(S.s_num) DESC  limit 1)