在mySQL中排序规则的非法组合

编程入门 行业动态 更新时间:2024-10-27 00:29:46
本文介绍了在mySQL中排序规则的非法组合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要将列从一个表传输到另一个表。源表具有与目标表不同的排序规则(latin1_general_ci和latin1_swedish_ci)。

I need to transfer a column from one table to another. The source table has a different collation than the target table (latin1_general_ci and latin1_swedish_ci).

我使用

UPDATE target LEFT JOIN source ON target.artnr = source.artnr SET target.barcode = source.barcode

I得到非法混合的整理。

I get an "illegal mix of collations".

什么是快速修复来获得这个工作,而不必更改任何表?我尝试CONVERT和COLLATE以UTF-8运行整个操作,但这没有帮助。 条形码只包含数字数据(即使它们都是VARCHAR),所以没有排序问题。

What is a quick fix to get this working without having to change either table? I tried CONVERT and COLLATE to run the whole operation in UTF-8, but that didn't help. "barcode" contains numeric data only (even though they all are VARCHARs), so there are no collation worries either way. I need to do this just once.

编辑:我使用 CAST(fieldname as unsigned) / code>在每个字段涉及。在这种情况下,我能够做到这一点,因为只有数字数据受到影响,但很高兴知道一个更一般的方法,这个问题,所以我打开这个问题。

I sorted it using a CAST(fieldname as unsigned) on every field involved. I was able to do that in this case because only numeric data was affected, but it would be nice to know a more general approach to this, so I am leaving the question open.

推荐答案

我尝试CONVERT和COLLATE以UTF-8运行整个操作,但是没有帮助。

I tried CONVERT and COLLATE to run the whole operation in UTF-8, but that didn't help.

它给我打了电话,所以今天我创建了这些表,并成功地运行了这个表:

It bugged me, so today I created those tables and successfully ran this one:

UPDATE target LEFT JOIN source ON( target.artnr = source.artnr COLLATE latin1_swedish_ci ) SET target.barcode = source.barcode

更多推荐

在mySQL中排序规则的非法组合

本文发布于:2023-11-22 05:21:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1616119.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:组合   规则   mySQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!