开发者

Only one expression can be specified in the select list

开发者 https://www.devze.com 2023-03-07 05:31 出处:网络
I need to get this sql query working: SELECTTOP 15 id, thumb, width, height FROM(SELECTvPictures.id, vPictures.thumb, vPictureCrops.width, vPictureCrops.height

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')
                       GROU开发者_StackOverflowP 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)"


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

USE AdventureWorks2008R2;
GO
SELECT p.FirstName, p.LastName
FROM Person.Person AS p
    JOIN Sales.SalesPerson AS sp
    ON p.BusinessEntityID = sp.BusinessEntityID
WHERE p.BusinessEntityID IN
   (SELECT BusinessEntityID
   FROM Sales.SalesPerson
   WHERE SalesQuota > 250000);
GO

Not sure what you are trying to achieve with the query anyway, can you explain the usage of the where in clause,


I can see two problems with (id NOT IN (SELECT TOP 0 vPictures_1.id, ...

  1. only when column should be specified in the select statement after IN. For example (id NOT IN (SELECT vPictures_1.id FROM ...

  2. even if you make it just one field vPictures_1.id the condition will always be false because of top 0.

0

精彩评论

暂无评论...
验证码 换一张
取 消