1

我试图执行以下查询

SELECT  Scania.GensetType, Scania.EngineType, Scania.Engine60Hz, Scania.Alternator, Scania.PriceEur
FROM Scania  
LEFT JOIN NordhavnGenset
    ON Scania.GensetType=NordhavnGenset.Alternator 
LEFT JOIN Generator
    ON Scania.Alternator=Generator.Alternator
LEFT JOIN Insulation 
    ON NordhavnGenset.Insulation=Insulation.Insulation
LEFT JOIN Klasse
    ON NordhavnGenset.Class=Klasse.Class
LEFT JOIN AirInletFilter
    ON NordhavnGenset.AirInletFilter=AirInletFilter.AirInletFilter
LEFT JOIN IP
    ON NordhavnGenset.Ip=IP.IP
WHERE (NordhavnGenset.MaxKva='46') and (Generator.Alternator='ECP34-1LN/4') and (Insulation.Insulation='F (90ºC/45ºC)') and (Klasse.Klasse='KRS\r') and (AirInletFilter.AirInletFilter='No') and (IP.IP='IP23');

然而似乎

Scania.Alternator=Generator.Alternator

数据类型分别为 text UTF 16 和 text UTF8。结果,它无法执行。我需要知道应该用于进行此转换的语法

这是我在执行查询时收到的错误消息

#1267 - Illegal mix of collations (utf16_unicode_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation '='
4

1 回答 1

2

您可以使用该CONVERT(.. USING ..)函数将值从一种字符编码转换为另一种:

Scania.Alternator = CONVERT(Generator.Alternator USING ucs2)

或者,您可以查看列编码不同的原因,并考虑对所有内容使用 utf8 或 ucs2 ...

于 2012-06-19T19:58:54.260 回答