为什么这个简单的MySQL子查询不起作用?(Why doesn't this simple MySQL subquery work?)

编程入门 行业动态 更新时间:2024-10-27 19:29:37
为什么这个简单的MySQL子查询不起作用?(Why doesn't this simple MySQL subquery work?)

此查询实际上与我显示的工作示例相同:

SELECT * FROM entities.entities WHERE entities.entities.id = (SELET MAX(entities.entities.id) FROM entities.entities);

这个查询开始时要简单得多,但我一直在添加数据库和表名,以确保查询无可挑剔。

它产生了不那么有用的错误:

SQL错误(1064):您的SQL语法中有错误; 检查与MySQL服务器版本对应的手册,以便在第3行使用“MAX(id)FROM entities”附近的正确语法

我已经确定我有MySQL版本5+,我已经确保子查询是一个标量子查询,即它只返回一行有一行,并且在查询的WHERE部分中受支持。

我觉得它没有错。

进入专家!

This query is virtually identical to the working example I was shown:

SELECT * FROM entities.entities WHERE entities.entities.id = (SELET MAX(entities.entities.id) FROM entities.entities);

This query was much simpler to begin with, but I've been adding database and table names everywhere just to be certain the query is impeccable.

It produces the not-so-helpful error:

SQL Error (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 'MAX(id) FROM entities)' at line 3

I've made sure I have MySQL version 5+, I've made sure the subquery is a scalar subquery, that is it returns only one column with one row, and is supported in the WHERE section of the query.

I see nothing wrong with it.

Enter the experts!

最满意答案

您的代码应为:

SELECT * FROM entities.entities WHERE entities.entities.id = (SELECT MAX(entities.entities.id) FROM entities.entities);

(你拼错了“SELECT”作为“SELET。”)

Your code should read:

SELECT * FROM entities.entities WHERE entities.entities.id = (SELECT MAX(entities.entities.id) FROM entities.entities);

(You had misspelled "SELECT" as "SELET.")

更多推荐

本文发布于:2023-07-26 05:14:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1271381.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不起作用   简单   MySQL   work   simple

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!