SQLServer中,在WHERE条件中使用别名,列名无效
SELECTTEMP.ROWID,P.ID,P.SORT,P.PDT_BASIC_CODE,P.PDT_BASIC_TITLE,P.PDT_TYPE_TITLE,P.PD...
SELECT TEMP.ROWID ,
P.ID ,
P.SORT ,
P.PDT_BASIC_CODE ,
P.PDT_BASIC_TITLE ,
P.PDT_TYPE_TITLE ,
P.PDTPRO ,
P.PDTPIC ,
P.PDTPIC1 ,
P.PDTPRICE ,
P.CUS_BASIC_CODE ,
P.CUS_BASIC_TITLE ,
P.PRICETABLENAME ,
P.BASEUNIT_TITLE ,
P.PDTSTANDARD ,
ISNULL(P.CUS_BASIC_TITLE, '') + ISNULL(P.PDT_TYPE_TITLE, '')
+ ISNULL(P.PDT_BASIC_TITLE, '') + ISNULL(P.PDTPRO, '')
+ ISNULL(P.BRAND, '') + ISNULL(P.PDTPRICE, '') AS PDT ,
P.BRAND ,
P.PDTAREA ,
P.NEWDATE ,
B.DIC_AREA_CODE ,
B.DIC_AREA_TITLE
FROM CUS_PRODUCT P
INNER JOIN CUS_BASIC B ON B.CODE = P.CUS_BASIC_CODE ,
( SELECT TOP ( ( 1 - 1 ) * 25 + 25 )
ROW_NUMBER() OVER ( ORDER BY SORT DESC ) ROWID ,ID
FROM CUS_PRODUCT P
WHERE 1 = 1
AND PDT LIKE '%四川%' 求代码能让这句生效
) TEMP
WHERE P.IFUSED = 1
AND P.ID = TEMP.ID
AND TEMP.ROWID > ( ( 1 - 1 ) * 25 )
ORDER BY TEMP.ROWID ASC
一定要用别名,因为别人的工具类写好了,自动生成的就是这个,不好弄 展开
P.ID ,
P.SORT ,
P.PDT_BASIC_CODE ,
P.PDT_BASIC_TITLE ,
P.PDT_TYPE_TITLE ,
P.PDTPRO ,
P.PDTPIC ,
P.PDTPIC1 ,
P.PDTPRICE ,
P.CUS_BASIC_CODE ,
P.CUS_BASIC_TITLE ,
P.PRICETABLENAME ,
P.BASEUNIT_TITLE ,
P.PDTSTANDARD ,
ISNULL(P.CUS_BASIC_TITLE, '') + ISNULL(P.PDT_TYPE_TITLE, '')
+ ISNULL(P.PDT_BASIC_TITLE, '') + ISNULL(P.PDTPRO, '')
+ ISNULL(P.BRAND, '') + ISNULL(P.PDTPRICE, '') AS PDT ,
P.BRAND ,
P.PDTAREA ,
P.NEWDATE ,
B.DIC_AREA_CODE ,
B.DIC_AREA_TITLE
FROM CUS_PRODUCT P
INNER JOIN CUS_BASIC B ON B.CODE = P.CUS_BASIC_CODE ,
( SELECT TOP ( ( 1 - 1 ) * 25 + 25 )
ROW_NUMBER() OVER ( ORDER BY SORT DESC ) ROWID ,ID
FROM CUS_PRODUCT P
WHERE 1 = 1
AND PDT LIKE '%四川%' 求代码能让这句生效
) TEMP
WHERE P.IFUSED = 1
AND P.ID = TEMP.ID
AND TEMP.ROWID > ( ( 1 - 1 ) * 25 )
ORDER BY TEMP.ROWID ASC
一定要用别名,因为别人的工具类写好了,自动生成的就是这个,不好弄 展开
1个回答
展开全部
使用子查询呗
Select * from
(
SELECT TEMP.ROWID ,
P.ID ,
P.SORT ,
P.PDT_BASIC_CODE ,
P.PDT_BASIC_TITLE ,
P.PDT_TYPE_TITLE ,
P.PDTPRO ,
P.PDTPIC ,
P.PDTPIC1 ,
P.PDTPRICE ,
P.CUS_BASIC_CODE ,
P.CUS_BASIC_TITLE ,
P.PRICETABLENAME ,
P.BASEUNIT_TITLE ,
P.PDTSTANDARD ,
ISNULL(P.CUS_BASIC_TITLE, '') + ISNULL(P.PDT_TYPE_TITLE, '')
+ ISNULL(P.PDT_BASIC_TITLE, '') + ISNULL(P.PDTPRO, '')
+ ISNULL(P.BRAND, '') + ISNULL(P.PDTPRICE, '') AS PDT ,
P.BRAND ,
P.PDTAREA ,
P.NEWDATE ,
B.DIC_AREA_CODE ,
B.DIC_AREA_TITLE
FROM CUS_PRODUCT P
) T
INNER JOIN CUS_BASIC B ON B.CODE = T.CUS_BASIC_CODE ,
( SELECT TOP ( ( 1 - 1 ) * 25 + 25 )
ROW_NUMBER() OVER ( ORDER BY SORT DESC ) ROWID ,ID
FROM CUS_PRODUCT P
WHERE 1 = 1
AND T.PDT LIKE '%四川%' 求代码能让这句生效
) TEMP
WHERE T.IFUSED = 1
AND T.ID = TEMP.ID
AND TEMP.ROWID > ( ( 1 - 1 ) * 25 )
ORDER BY TEMP.ROWID ASC
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询