Question

in MySQL I am able to use LIMIT clause but not in the sybase. I have found a lot of question and answers on the net but I can't find what I want. I have tried this

    SELECT TOP 5 * FROM Employees ORDER BY Surname;

but sybase throws and error.it says incorrect syntax near 5. I have also tried this one

SELECT BOTTOM 5 * FROM
(SELECT TOP 15 * FROM someTable
ORDER BYorderColumns DESC)

also not working. and also this one:

SET ROWCOUNT 60
DECLARE @name VARCHAR
SELECT @name = name
FROM user
WHERE something = $something
ORDER BY date ASC

SET ROWCOUNT 20
SELECT *
FROM user
WHERE name >= @name

this is not working since I don't have any ID number in the table, but only name which has varchar data type. Any ideas guys? Thank you so much in advance.

Was it helpful?

Solution

I'm not sure which sybase do you use, but this:

SELECT TOP 5 * FROM Employees ORDER BY Surname

will work on ASE.

You can also try this way:

SELECT TOP(5) * FROM Employees ORDER BY Surname;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top