mysql配置文件/etc/my.cnf中加入character-set-server=utf8
启动mysql服务: service mysqld start或者/etc/init.d/mysqld start
开机启动:
添加开机启动:chkconfig --add mysqld
开机启动:chkconfig mysqld on
<p>可以的吧,出null是不是因为你字段的内容就是null啊。</p><p>
</p>
<p>这里是一个测试,可以看到使用列名value来做then的值是可以的:</p>
mysql>
select
*
from
aaa
+------+-------+
|
id
|
value
|
+------+-------+
|
1
|
1
|
|
2
|
3
|
|
3
|
4
|
|
4
|
4
|
|
5
|
4
|
|
6
|
6
|
|
8
|
8
|
|
7
|
7
|
|
9
|
8
|
|
10
|
10
|
|
11
|
11
|
|
12
|
11
|
|
13
|
11
|
|
14
|
11
|
|
15
|
12
|
+------+-------+
15
rows
in
set
(0.00
sec)
mysql>
select
id,
value,
case
id
when
1
then
value
when
2
then
2
*
value
when
3
then
'xxx'
else
0
end
as
case_col
->
from
aaa
+------+-------+----------+
|
id
|
value
|
case_col
|
+------+-------+----------+
|
1
|
1
|
1
|
|
2
|
3
|
6
|
|
3
|
4
|
xxx
|
|
4
|
4
|
0
|
|
5
|
4
|
0
|
|
6
|
6
|
0
|
|
8
|
8
|
0
|
|
7
|
7
|
0
|
|
9
|
8
|
0
|
|
10
|
10
|
0
|
|
11
|
11
|
0
|
|
12
|
11
|
0
|
|
13
|
11
|
0
|
|
14
|
11
|
0
|
|
15
|
12
|
0
|
+------+-------+----------+
15
rows
in
set
(0.00
sec)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)