sql - 选择不同的和内部连接图像数据类型

标签 sql distinct sql-server-2012

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

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/

相关文章:

sql-server - 一行查询中的多行

php - 数据库项目未显示在网页上

java - HSQLDB 子查询 - Java

android - 我应该如何编写 SQLite 查询?

sql join - 仅从第二个表中选择第一行

sql-server - 无法为数据库中的对象分配空间,因为 'PRIMARY' 文件组已满

sql-server - 构建 SSIS 项目时未创建 ispac

php - 如何编写查询来比较具有逗号分隔值的列?

sql - PSQL : select subquery and group by

C# Linq 如何选择数据表中多列的不同行数