请教一个sqlserver分页语句执行问题,请问哪里出错了? 在sql中一直执行,但是没有反应
SELECTTOP30a.P_Remark,a.P_Record,a.P_WCZZW,a.P_RecordDate,b.SD_Name,z.CWS_Name,z.CWS_...
SELECT TOP 30 a.P_Remark,a.P_Record,a.P_WCZZW,a.P_RecordDate,b.SD_Name,z.CWS_Name,z.CWS_CMID
FROM (Production a inner join SubDepartment b on a.P_SDID = b.SD_ID) inner join CoalWorkSpace z on a.P_WSID = z.CWS_ID where a.P_DelFlag=0 AND a.P_SDTID=1 and a.P_ID NOT IN
(SELECT TOP 30 a.P_ID FROM (Production a inner join SubDepartment b on a.P_SDID = b.SD_ID) INNER JOIN CoalWorkSpace z ON a.P_WSID = z.CWS_ID where a.P_DelFlag=0 AND a.P_SDTID=1 ORDER BY a.P_ID DESC) ORDER BY a.P_ID DESC 展开
FROM (Production a inner join SubDepartment b on a.P_SDID = b.SD_ID) inner join CoalWorkSpace z on a.P_WSID = z.CWS_ID where a.P_DelFlag=0 AND a.P_SDTID=1 and a.P_ID NOT IN
(SELECT TOP 30 a.P_ID FROM (Production a inner join SubDepartment b on a.P_SDID = b.SD_ID) INNER JOIN CoalWorkSpace z ON a.P_WSID = z.CWS_ID where a.P_DelFlag=0 AND a.P_SDTID=1 ORDER BY a.P_ID DESC) ORDER BY a.P_ID DESC 展开
展开全部
分段执行:看看效果:
SELECT TOP 30
a.P_ID FROM
Production a,
SubDepartment b,
CoalWorkSpace z
where a.P_SDID = b.SD_ID and a.P_WSID = z.CWS_ID and a.P_DelFlag=0 AND a.P_SDTID=1
ORDER BY a.P_ID DESC
看子查询能不能查出东西
然后
SELECT TOP 30
a.P_Remark,a.P_Record,a.P_WCZZW,a.P_RecordDate,b.SD_Name,z.CWS_Name,z.CWS_CMID
FROM
Production a,
SubDepartment b,
CoalWorkSpace z
where a.P_SDID = b.SD_ID and a.P_WSID = z.CWS_ID and a.P_DelFlag=0 AND a.P_SDTID=1
ORDER BY a.P_ID DESC
如果上面两个都有值那么,再在拆薯下面
SELECT TOP 30
a.P_Remark,a.P_Record,a.P_WCZZW,a.P_RecordDate,b.SD_Name,z.CWS_Name,z.CWS_CMID
FROM
Production a,
SubDepartment b,
CoalWorkSpace z
where a.P_SDID = b.SD_ID and a.P_WSID = z.CWS_ID and a.P_DelFlag=0 AND a.P_SDTID=1 and
a.P_ID NOT IN
(
SELECT TOP 30
a.P_ID FROM
Production a,
SubDepartment b,
CoalWorkSpace z
where a.P_SDID = b.SD_ID and a.P_WSID = z.CWS_ID and a.P_DelFlag=0 AND a.P_SDTID=1
ORDER BY a.P_ID DESC
)
ORDER BY a.P_ID DESC
关键是我还不知到三个表的inner join 是销御猜什么样的 但是 我可以做成如上我的效果一个亏型个加以验证,和你的代码其实是一样的 如果没错的话。你可以自己测试测试。不行,把数据库发给我 我来帮你测测 245002754@qq.com 希望能帮到你
SELECT TOP 30
a.P_ID FROM
Production a,
SubDepartment b,
CoalWorkSpace z
where a.P_SDID = b.SD_ID and a.P_WSID = z.CWS_ID and a.P_DelFlag=0 AND a.P_SDTID=1
ORDER BY a.P_ID DESC
看子查询能不能查出东西
然后
SELECT TOP 30
a.P_Remark,a.P_Record,a.P_WCZZW,a.P_RecordDate,b.SD_Name,z.CWS_Name,z.CWS_CMID
FROM
Production a,
SubDepartment b,
CoalWorkSpace z
where a.P_SDID = b.SD_ID and a.P_WSID = z.CWS_ID and a.P_DelFlag=0 AND a.P_SDTID=1
ORDER BY a.P_ID DESC
如果上面两个都有值那么,再在拆薯下面
SELECT TOP 30
a.P_Remark,a.P_Record,a.P_WCZZW,a.P_RecordDate,b.SD_Name,z.CWS_Name,z.CWS_CMID
FROM
Production a,
SubDepartment b,
CoalWorkSpace z
where a.P_SDID = b.SD_ID and a.P_WSID = z.CWS_ID and a.P_DelFlag=0 AND a.P_SDTID=1 and
a.P_ID NOT IN
(
SELECT TOP 30
a.P_ID FROM
Production a,
SubDepartment b,
CoalWorkSpace z
where a.P_SDID = b.SD_ID and a.P_WSID = z.CWS_ID and a.P_DelFlag=0 AND a.P_SDTID=1
ORDER BY a.P_ID DESC
)
ORDER BY a.P_ID DESC
关键是我还不知到三个表的inner join 是销御猜什么样的 但是 我可以做成如上我的效果一个亏型个加以验证,和你的代码其实是一样的 如果没错的话。你可以自己测试测试。不行,把数据库发给我 我来帮你测测 245002754@qq.com 希望能帮到你
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询