mirror of
https://gitee.com/johng/gf.git
synced 2024-11-30 03:07:45 +08:00
Fix the bug of MSSQL paging
This commit is contained in:
parent
6174097a07
commit
f667cbc2a2
@ -153,17 +153,15 @@ func (d *DriverMssql) parseSql(sql string) string {
|
||||
"SELECT * FROM "+
|
||||
"(SELECT ROW_NUMBER() OVER (ORDER BY %s) as ROWNUMBER_, %s ) as TMP_ "+
|
||||
"WHERE TMP_.ROWNUMBER_ > %d AND TMP_.ROWNUMBER_ <= %d",
|
||||
orderStr, selectStr, first, limit,
|
||||
orderStr, selectStr, first, first+limit,
|
||||
)
|
||||
} else {
|
||||
if first == 0 {
|
||||
first = limit
|
||||
} else {
|
||||
first = limit - first
|
||||
}
|
||||
sql = fmt.Sprintf(
|
||||
"SELECT * FROM (SELECT TOP %d * FROM (SELECT TOP %d %s) as TMP1_ ) as TMP2_ ",
|
||||
first, limit, selectStr,
|
||||
limit, first+limit, selectStr,
|
||||
)
|
||||
}
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user