简体   繁体   English

操作数类型冲突:uniqueidentifier 与 float 不兼容

[英]Operand type clash: uniqueidentifier is incompatible with float

I have the following SQL statement:我有以下 SQL 声明:

select pc.*,au.UserName from ProspectsInCampaigns pc 
inner join prospects p on p.id=pc.prospectid 
inner join aspnet_Users au on STR(au.UserId)=pc.updatedby
WHERE p.id=1225982

The problem is, that the updatedby field in ProspectsInCampaigns contains either an empty string, or a string that is indeed a UUID.问题是,ProspectsInCampaigns 中的 updatedby 字段要么包含一个空字符串,要么包含一个确实是 UUID 的字符串。 In the above case I get the error:在上述情况下,我收到错误:

Operand type clash: uniqueidentifier is incompatible with float操作数类型冲突:uniqueidentifier 与 float 不兼容

How can I prevent that from happening?我怎样才能防止这种情况发生?

Don't compare the UUID to a float .不要将UUIDfloat进行比较。 Why are you doing that anyways?你为什么要这样做?

You can consult this handy chart to know what conversions are allowed.您可以查阅这个方便的图表以了解允许进行哪些转换。 If you can't convert two datatypes to each other, you can't compare them directly.如果不能将两种数据类型相互转换,就不能直接比较它们。

Hypothetically you could convert both to a string type like varchar but since it's impossible to have a UUID match anything that can be a float there's no point.假设您可以将两者都转换为像varchar这样的字符串类型,但由于UUID不可能匹配任何可以是float的东西,所以没有意义。

Edit:编辑:

More specifically, it looks like Userid is a UUID and the STR() function is specifically for converting float data to a string datatype.更具体地说,看起来Userid是一个UUID ,而STR() function 专门用于将float数据转换为字符串数据类型。

Why are you trying to convert au.UserID anyway?你为什么要转换 au.UserID 呢? If you have a UUID, compare it to the other UUID directly.如果您有 UUID,请直接将其与另一个 UUID 进行比较。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 操作数类型冲突:uniqueidentifier与查询中的int不兼容 - Operand type clash: uniqueidentifier is incompatible with int in query 操作数类型冲突:uniqueidentifier与int不兼容 - Operand type clash: uniqueidentifier is incompatible with int 存储过程-操作数类型冲突:smallint与uniqueidentifier不兼容 - Stored procedure - Operand type clash: smallint is incompatible with uniqueidentifier 操作数类型冲突:时间与浮点计算不兼容 - Operand type clash: time is incompatible with float for compute SQL语句不起作用-“操作符类型冲突:float与日期不兼容” - SQL statement not working - "Operand type clash: float is incompatible with date' 尝试在参数中添加“ ALL”选项时,操作数类型冲突uniqueidentifier与int不兼容 - operand type clash uniqueidentifier is incompatible with int when trying to add 'ALL' option to my parameter 操作数类型冲突:NULL与A表类型不兼容 - Operand type clash: NULL is incompatible with A table type 操作数类型冲突:日期与 smallint 不兼容 - Operand type clash: date is incompatible with smallint 操作数类型冲突:图像与varchar(max)不兼容 - Operand type clash: image is incompatible with varchar(max) 操作数类型冲突:日期与int不兼容? - Operand type clash: date is incompatible with int?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM