暂无图片
暂无图片
暂无图片
暂无图片

MySQL ERROR 1406 (22001): Data too long for column 'c1' at row 1

只是甲 2021-12-21
961

Table of Contents

一.问题描述

测试数据:

drop table test; create table test (pid varchar(200),id varchar(200)); insert into test values (null,'中国'); insert into test values ('中国','广东'); insert into test values ('中国','广西'); insert into test values ('广东','深圳'); insert into test values ('深圳','福田'); with RECURSIVE t(pid,c1,c2,c3,lvl,id) as ( select id,null,null,null,1,id from test where pid is null union all select t.pid ,case when t.lvl=1 then test.id else t.c1 end as c1 ,case when t.lvl=2 then test.id else t.c2 end as c2 ,case when t.lvl=3 then test.id else t.c3 end as c3 ,t.lvl+1 ,test.id from t ,test where t.id=test.pid select * from t

运行报错: