Server: MariaDB, version 10.4.17
Query:
select something from (select 1, 2 as something)
Error in phpMyAdmin:
#1064 - Something is wrong in your syntax 'LIMIT 0, 25'
Error in MySQL Workbench:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'LIMIT 0, 1000' at line 2 0.000 sec
All right so MariaDB decided to
- modify my query
- throw error that shouldn’t be thrown
Let’s find out what is wrong with select something from (select 1, 2 as something) limit 123
:
#1064 - Something is wrong in your syntax near 'limit 123'
I restarted the server and this error still occurs.
2
Answers
is to vague to pinpoint the cause of the 1064, but here is another error — You must have an ‘alias’ on the derived table:
This
Is giving an alias to the constant
2
.Both phpMyAdmin and MySQL Workbench will add "LIMIT" clause to the end of your query automatically, this is why you’re getting this misleading message.
But the root cause of the problem is that you need to provide an alias for the sub query, e.g.