除非使用IS NULL或LIKE运算符,否则无法比较或排序text,ntext和image数据类型。 [英] The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.

查看:114
本文介绍了除非使用IS NULL或LIKE运算符,否则无法比较或排序text,ntext和image数据类型。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Use Shoppingkart
select P.ProductSNo,
P.ProductName,
P.ProductDescription,
P.ProductPrice,
P.ProductImage,
P.CategorySNo,
P.CategorySNo,
P.ProductQuantity,
C.CategoryName,
Isnull(Sum(CP.TotalProducts),0) as ProductSold

From Products P
Inner Join Category C
On P.CategorySNo=C.CategorySNo

LEFT Join CustomerProducts CP
On P.ProductSNo=CP.ProductSNo

Group BY
P.ProductSNo,
P.ProductName,
P.ProductDescription,
P.ProductPrice,
P.ProductImage,
P.CategorySNo,

P.ProductQuantity,
C.CategoryName





我收到此错误::





I got This error::

The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.

推荐答案

正如错误所述,某些数据类型无法比较。在你的陈述中我猜它是 P.ProductImage



一个选项是你首先选择'正常'数据然后使用该结果集并将其与图像数据组合。换句话说,比如



As the error says, some of the data types aren't comparable. In your statement I'd guess it's P.ProductImage.

One option is that you first select the 'normal' data and then use that result set and combine it with the image data. In other words, something like

select a.*,
       (select p.productimage 
        from product p
        where p.productsno = a.productsno) AS ProductImage
from (
      select P.ProductSNo,
      P.ProductName,
      P.ProductDescription,
      P.ProductPrice,
      P.CategorySNo,
      P.CategorySNo,
      P.ProductQuantity,
      C.CategoryName,
      Isnull(Sum(CP.TotalProducts),0) as ProductSold
      From Products P
      Inner Join Category C
      On P.CategorySNo=C.CategorySNo
      LEFT Join CustomerProducts CP
      On P.ProductSNo=CP.ProductSNo
      Group BY
      P.ProductSNo,
      P.ProductName,
      P.ProductDescription,
      P.ProductPrice,
      P.CategorySNo,
      P.ProductQuantity,
      C.CategoryName) a



示例中的连接列可能不正确,但您知道结构更好的数据库:)


The joining column may be incorrect in the example, but you know the structure of the database better :)


这篇关于除非使用IS NULL或LIKE运算符,否则无法比较或排序text,ntext和image数据类型。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆