|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have used this mysql code in my programm before:
select * from address order by vorname asc limit 0, 10 It works fine. But now I want to use sql server, and it doesn't recognize the term limit. So I have found out that I can use top instead. I have changed my code into this: select top 0 * from (select top 10* from address order by vorname) order by vorname asc But it gives me an error message: wrong syntax near the word Order. Can anyone give me a solution? Thank you. |
|
#2
|
|||
|
|||
|
Why complicate matters?
Code:
select top 10* from address order by vorname |
|
#3
|
|||
|
|||
|
Sorry, my mistake
it works fine if the limit is 0,10 but what if the limit is 10,10 ? Thank you |
|
#4
|
|||
|
|||
|
Code:
select top 10 * from address where vorname not in (select top 10 vorname from adress order by vorname) order by vorname |
|
#5
|
|||
|
|||
|
Problem with sorting
Quote:
I'm afraid this won't really help. look at this example : id |val ---+--- 1 | aa 2 | aa 3 | bb 4 | bb "SELECT * ORDER BY val ASC" will return 1,aa 2,aa 3,bb 4,bb "SELECT * ORDER BY val DESC" will return 3,bb 4,bb 1,aa 2,aa Vou see, this isn't what we would expect under MySQL. MSSQL doesn't actually reverse the recordset with your approach. |
|
#6
|
|||
|
|||
|
Quote:
What recordset? There is no order to reverse. If you order by a column which have duplicates you can't predict anything about the order within the group. To get the order id val ----- 4 bb 3 bb 2 aa 1 aa you must use Code:
order by val desc,id desc |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Limit in mysql = top in sql server ? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|