小编Shu*_*ali的帖子

MySql 在视图中更改排序规则

我在 mysql 中有一个视图“name_all”,它的结构是

colName     varchar(30)  utf8_general_ci

date    varchar(76)     utf8_general_ci

name  varchar(43)   latin1_swedish_ci
Run Code Online (Sandbox Code Playgroud)

当我尝试运行查询时:

SELECT CONCAT(`colname`,' of Mr. ',`name`,' Expire on ',`date`) FROM name_all
Run Code Online (Sandbox Code Playgroud)

它给出错误:

 #1271 - Illegal mix of collations for operation 'concat'

"colName" is basically a Column Name which is used as a row in this View

"date" is mysql Date which is converted in this format '%a %D %b, %Y'

"name" is concatenation of firstname, middlename, lastname from a table
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题,我的错误是什么?

当我运行查询 SHOW VARIABLES LIKE 'collat​​ion%' 结果是

  Variable_name …
Run Code Online (Sandbox Code Playgroud)

mysql concat collation

4
推荐指数
2
解决办法
9156
查看次数

mysql将列转换为行

我有一个视图,是从多个表视图结构创建的

id     col1     col2     col3     col4

101     A     B     B     NULL

102     C     F     A     G
Run Code Online (Sandbox Code Playgroud)

等等(这是样本)

我想创建另一个看起来像的视图

ID     col_name     value

101     col1     A

101     col2     B

101     col3     B

101     col4     NULL

102     col1     C

102     col2     F

102     col3     A

102     col4     G
Run Code Online (Sandbox Code Playgroud)

等等

任何人都可以帮助plzzz

mysql

2
推荐指数
1
解决办法
9054
查看次数

标签 统计

mysql ×2

collation ×1

concat ×1