mysql转化成sqlserver怎么去写,想了半天还是没搞定!
select smsId, mtId,taskId, content, userId, orgid, receivetime,
mobilephone, destAddr, status
from t_websms_receivedsms where 1=1 and userid=1
and status= '0 'order by receivetime desc
limit m,n
这是一条mysql语句,现在要转化成sqlserver语句,做了半天还是没做出来,我知道用select top n * from t_websms_receivedsms where smsId not in(select top
m-1 id from t_websms_receivedsms )
可具体怎么去写我还是没写出来
请高手指教.解决的立马一百只要我验证正确就ok.
------解决方案--------------------问题在limit,这是MySQL的方言。
SQL Server里面你可以用top.
呵呵。千真万确哦。
------解决方案--------------------先正向排序取n条,再逆向排序取m条数据就ok了
--------
select top m * from
(select top n * from t_websms_receivedsms order by receivetime )
order by receivetime desc
------解决方案--------------------select smsId, mtId,taskId, content, userId, orgid, receivetime,
mobilephone, destAddr, status
from t_websms_receivedsms where userid=1
and status= '0 '
and eceivetime> =(
select top m max(receivetime) where userid=1
and status= '0 ' order by receivetime desc)
and eceivetime <=(
select top n max(receivetime) where userid=1
and status= '0 ' order by receivetime desc)
order by receivetime desc