on 2012 Dec 06 9:53 AM
Is the LIMIT statement supported? I'm trying to use the FuelPHP ORM library. It's generating a query that works with MySQL but doesn't seem to with SQLAnywhere. I've traced it down to the query below.
Working MySQL example:
SELECT * FROM users
ORDER BY id ASC LIMIT 1
SQLAnywhere example that doesn't work:
SELECT * FROM EM.Users ORDER BY UserId ASC LIMIT 1
Similar SQLAnywhere example that does work (by removing LIMIT):
SELECT * FROM EM.Users ORDER BY UserId ASC
Request clarification before answering.
LIMIT is available with v12 but has to be "allowed" explicitly. From the docs:
The following statement allows the LIMIT keyword to be recognized as a keyword:
SET OPTION PUBLIC reserved_keywords = 'LIMIT';
EDIT: As Reimer has noted, the doc sample is missing a period, it should read
SET OPTION PUBLIC.reserved_keywords = 'LIMIT';
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I believe the equivalent SQL/Anywhere syntax is
SELECT TOP 1 * FROM users ORDER BY id ASC
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just to clarify:
The TOP / FIRST [START AT] clause is SQL Anywhere'c "classical" row limitation clause, available since v6 or v7, methinks. AFAIK it's not SQL standard, however supported by ASE and MS SQL Server, too.
v12 has added the LIMIT [OFFSET] clause, presumably for MySQL compatibility.
User | Count |
---|---|
61 | |
8 | |
7 | |
6 | |
6 | |
4 | |
4 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.