我需要一行PostgreSQL

时间:2017-06-08 19:04:23

标签: sql postgresql

我需要一个可以返回多行的PostgreSQL子查询。这是我到目前为止的查询部分:

select (SELECT ARRAY[url, thumb_1, thumb_200, thumb_500]
                FROM "Image"
                LEFT JOIN "Product_Image"
                ON "Image".id = "Product_Image".image_id
                WHERE "Product_Image".product_id = 517
                ORDER BY "Product_Image".sort ASC) as images

1 个答案:

答案 0 :(得分:0)

将子查询放在FROM子句中吗?

select vals
from (SELECT ARRAY[url, thumb_1, thumb_200, thumb_500] as vals
      FROM "Image" LEFT JOIN
           "Product_Image"
           ON "Image".id = "Product_Image".image_id
      WHERE "Product_Image".product_id = 517
     ) images