开发者

Why doesn't this simple MySQL subquery work?

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 entitie开发者_如何学编程s.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!


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.")


Try this:

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


You mis-spelled select:

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


Yeah Make sure to check your code first.

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

SELET --> SELECT

Regards

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜