Syntax error near limit

Asked

Viewed 239 times

0

Can someone help me?

I have the following query:

select coluna1, coluna2, coluna3 from tabela
where coluna2 > 0 
order by coluna3 desc
limit 10

And when I execute the following error appears:

Msg 102, Level 15, State 1, Line 6
 Incorrect syntax near 'limit'- 

Error image

  • SELECT * FROM table WHERE column2 >= '0' ORDER BY column3 DESC LIMIT 0,10

  • It wouldn’t be like this?

  • I tested it this way and kept making the same mistake

  • Post the whole code, please.

  • 1

    Your Query looks right, are you really using mysql? is not an mssql or sql server?

  • I think you are using another database other than Mysql. If it is SQL Server it is top.

  • I was able to solve the problem using Diego Souza’s solution. Thank you for your help!

Show 2 more comments

1 answer

5


Mysql - Using the LIMIT.

SELECT
    coluna1,
    coluna2,
    coluna3
FROM
    tabela
WHERE
    coluna2 > 0
ORDER BY
    coluna3 DESC
LIMIT 10

SQL Server - Using TOP.

SELECT TOP 10
    coluna1,
    coluna2,
    coluna3
FROM
    tabela
WHERE
    coluna2 > 0
ORDER BY
    coluna3 DESC
  • I managed to solve the problem using SELECT TOP 10. Thank you very much!

  • Perfect @Lorennachristna just accept his answer as correct. Left side, below the votes. :)

  • 2

    I was just looking for where it was done hahahaha! Super thank you! :)

Browser other questions tagged

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