Skip to content
Advertisement

MySQL – #1064 – Something is wrong in your syntax ‘LIMIT 0, 25’

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

  1. modify my query
  2. 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.

Advertisement

Answer

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.

select something from (select 1, 2 as something) as t1
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement