我尝试选择所有已下订单的唯一客户,但当我尝试包含照片时出现错误。
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
这会产生以下错误:
The image data type cannot be selected as DISTINCT because it is not comparable.
最佳答案
查询应该是
select * from customers where id in (select customerID from orders)
关于sql - 选择不同的和内部连接图像数据类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11410333/