[英]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
.不要将UUID
与float
进行比较。 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.