CREATE TABLE test ( id int(11) NOT NULL auto_increment, description text collate utf8_bin NOT NULL, ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;这是原表,我想建立个视图,类似上表 create view v_test(id int,des varchar(300)) as select id,description[需要转换这个字段为varchar] from test
create view v_test as select id,cast(description as varchar(200) from test
建议你列出你的表结构,并提供测试数据以及基于这些测试数据的所对应正确结果。
参考一下这个贴子的提问方式http://forum.csdn.net/BList/OtherDatabase
1. 你的 create table xxx .. 语句
2. 你的 insert into xxx ... 语句
3. 结果是什么样,(并给以简单的算法描述)
这样想帮你的人可以直接搭建和你相同的环境,并在给出方案前进行测试。
CREATE TABLE test (
id int(11) NOT NULL auto_increment,
description text collate utf8_bin NOT NULL,
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;这是原表,我想建立个视图,类似上表 create view v_test(id int,des varchar(300)) as select id,description[需要转换这个字段为varchar] from test
但是 yangxiao_jiang 说的直接cast好像测试不通过