i save a new rows .. and it is saved so
id, user, message i want to get the last 25 saved but whit this
select top 25 usuario, mensaje
from chat
order by idchat asc
I just get the first 25, 开发者_如何学Pythonhow can i get the last 25 rows?
the table is it
create table chat
(idchat int primary key identity,
usuario varchar(50),
mensaje text);
if i execute
select top 25 usuario, mensaje from chat order by idchat desc
it return a bad thing.. for example i a saved
'user1','mensaje1'
'user1','mensaje2'
'user1', 'mensaje3'
this returns
'user1','mensaje3'
'user1','mensaje2'
'user1', 'mensaje1'
I dont need it..
Change ASC to DESC:
select top 25 usuario, mensaje from chat order by idchat desc
Edit: you want the last 25, but after filtering for the last 25, you want them ordered ascending?
SELECT * FROM
(
select top 25
usuario,
mensaje
from
chat
order by
idchat desc
)
ORDER BY
idchat ASC
精彩评论