选择列表中只能指定一个表达式
我需要让这个 sql 查询正常工作:
SELECT TOP 15 id, thumb, width, height
FROM (SELECT vPictures.id, vPictures.thumb, vPictureCrops.width, vPictureCrops.height
FROM vPictures INNER JOIN
vPictureCrops ON vPictures.id = vPictureCrops.picid
WHERE (vPictureCrops.width = '602') AND (vPictureCrops.height = '131')
GROUP BY vPictures.id, vPictures.thumb, vPictureCrops.width, vPictureCrops.height) AS derivedtbl_1
WHERE (id NOT IN
(SELECT TOP 0 vPictures_1.id, vPictures_1.datetime, vPictures_1.url, vPictures_1.author, vPictures_1.companyID, vPictures_1.source,
vPictures_1.people, vPictures_1.text, vPictures_1.thumb, vPictures_1.logo, vPictureCrops_1.id AS Expr1, vPictureCrops_1.picid,
vPictureCrops_1.url AS Expr2, vPictureCrops_1.width, vPictureCrops_1.height
FROM vPictures AS vPictures_1 INNER JOIN
vPictureCrops AS vPictureCrops_1 ON vPictures_1.id = vPictureCrops_1.picid))
ORDER BY id DESC
你能帮我吗?
错误信息: “当子查询不带 EXISTS 引入时,选择列表中只能指定一个表达式)”
I need to get this sql query working:
SELECT TOP 15 id, thumb, width, height
FROM (SELECT vPictures.id, vPictures.thumb, vPictureCrops.width, vPictureCrops.height
FROM vPictures INNER JOIN
vPictureCrops ON vPictures.id = vPictureCrops.picid
WHERE (vPictureCrops.width = '602') AND (vPictureCrops.height = '131')
GROUP BY vPictures.id, vPictures.thumb, vPictureCrops.width, vPictureCrops.height) AS derivedtbl_1
WHERE (id NOT IN
(SELECT TOP 0 vPictures_1.id, vPictures_1.datetime, vPictures_1.url, vPictures_1.author, vPictures_1.companyID, vPictures_1.source,
vPictures_1.people, vPictures_1.text, vPictures_1.thumb, vPictures_1.logo, vPictureCrops_1.id AS Expr1, vPictureCrops_1.picid,
vPictureCrops_1.url AS Expr2, vPictureCrops_1.width, vPictureCrops_1.height
FROM vPictures AS vPictures_1 INNER JOIN
vPictureCrops AS vPictureCrops_1 ON vPictures_1.id = vPictureCrops_1.picid))
ORDER BY id DESC
Can you help me?
The error message:
"Only one expression can be specified in the select list when the subquery is not introduced with EXISTS)"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Where (ID not IN(
选择必须只有一个字段,IN 无法理解您要解析的列。
例如来自 here
无论如何,不确定您想通过查询实现什么目的,您能否解释一下 where in 子句的用法,
The Where (ID not IN(
The Select must only have one field are the IN can not understand which column you are trying to parse.
Eg from here
Not sure what you are trying to achieve with the query anyway, can you explain the usage of the where in clause,
我可以看到
(id NOT IN (SELECT TOP 0 vPictures_1.id, ...
仅当应在 IN 之后的
select
语句中指定列时出现 两个问题例如(id NOT IN (SELECT vPictures_1.id FROM ...
)
即使您将其设为一个字段
vPictures_1.id
,由于top 0
,条件也将始终为 false。I can see two problems with
(id NOT IN (SELECT TOP 0 vPictures_1.id, ...
only when column should be specified in the
select
statement after IN. For example(id NOT IN (SELECT vPictures_1.id FROM ...
even if you make it just one field
vPictures_1.id
the condition will always be false because oftop 0
.