skip to Main Content

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.

2

Answers


  1. select something from (select 1, 2 as something) limit 123
    

    is to vague to pinpoint the cause of the 1064, but here is another error — You must have an ‘alias’ on the derived table:

    select something from (select 1, 2 as something) AS x limit 123
    

    This

    2 as something
    

    Is giving an alias to the constant 2.

    Login or Signup to reply.
  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.

    select something from (select 1, 2 as something) as t1
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search