How do ORDER BY DESC work in Mysql?

Asked

Viewed 548 times

0

I am trying to make a query on my table using OREDER BY DESC, even using the correct syntax I get the error: "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 'ORDER BY IDADE DESC' at line 5".

The table I’m using as an example is this:

CREATE TABLE PESSOA
    (`nome` varchar(8), `idade` int, `estado_nascimento` varchar(2))
;

INSERT INTO PESSOA
    (`nome`, `idade`, `estado_nascimento`)
VALUES
    ('joao', 12, 'sp'),
    ('maria', 26, 'rj'),
    ('joao', 15, 'mg'),
    ('fernanda', 30, 'ce')
;

And the consultation I’m doing is this:

SELECT NOME
FROM PESSOA
WHERE ESTADO_NASCIMENTO NOT IN ('CE')
LIMIT 1
ORDER BY IDADE DESC;

Follow the SQL Fiddle link with the table and query for convenience: http://sqlfiddle.com/#! 9/caf268/1

Would anyone know what I’m missing?

P.S.: I am using Mysql 5.6

  • You have to delete that question?

1 answer

2


Browser other questions tagged

You are not signed in. Login or sign up in order to post.