2

我正在尝试选择所有已下订单的唯一客户,但是当我尝试包含照片时出现错误。

Order Table
ID      |  CustomerID
-----------------------
1       |  2
2       |  1
3       |  2


Customer Table
ID      | Name   | Photo (image, null)
--------------------------
1       | John   | image
2       | Adam   | image
3       | Jack   | image


Expected result
   CustomerID  | Name   | Photo
--------------------------------
1              | John   | image
2              | Adam   | image

到目前为止我的查询:

SELECT Distinct o.CustomerID, c.Name, c.Photo
FROM Order o 
inner join Customer c on o.CustomerID = o.ID

这给出了以下错误:

图像数据类型不能选择为 DISTINCT,因为它不可比较。

4

1 回答 1

3

查询应该是

select * from customers where id in (select customerID from orders)
于 2012-07-10T09:35:00.443 回答