在对条件需要用到子查询的时候,通常可以通过连接来代替子查询来完成操作,更加高效
SELECT t1.id,t2.columnName,t2.columnType,t1.rownum,t1.cellValue FROM dbo.t_dataPublishDetail t1
INNER JOIN dbo.t_dataPublishColumn t2 ON t1.t_dataPublishColumn_id = t2.id AND t2.t_dataPublish_id = 36
INNER JOIN (
SELECT rownum FROM dbo.t_dataPublishDetail t1
INNER JOIN dbo.t_dataPublishColumn t2 ON t1.t_dataPublishColumn_id = t2.id AND t_dataPublish_id = 36 AND columnType=7
WHERE t1.cellValue='10000'
) t3 ON t3.rownum=t1.rownum
ORDER BY t1.rownum