Oracle syntax error [duplicate]
Asked Answered
U

1

7

I got the following error in Oracle:

SELECT * FROM abcd WHERE name LIKE 'a%' LIMIT 10
                                        *
ERROR at line 1:
ORA-00933: SQL command not properly ended

What is the problem with the command?

Unwearied answered 1/3, 2010 at 8:38 Comment(0)
S
15

Oracle doesn't support the limit clause. That's a MySQL/Postgres thing.

There are alternatives, although they're often a lot more involved

http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html

The simplest equivalent is:

select * from abcd where name like 'a%' and ROWNUM <= 10;
Stonewall answered 1/3, 2010 at 8:47 Comment(4)
then i want to limit the keywords to 10 for a specific search what should i doUnwearied
Please be careful when limiting query results using <rownum in combination with an order by clause. You may not get the results you expect. Oracle first limits the number of rows and then does the sort.Incardinate
@Rene: Indeed, it can bite you. In this case, though, it doesn't seem to matter.Stonewall
LIMIT is supported on MySQL and PostgresPronucleus

© 2022 - 2024 — McMap. All rights reserved.