SELECT cbdl_code, CASE WHEN LENGTH(cbdl_code) = 1 THEN name WHEN LENGTH(cbdl_code) = 3 THEN CONCAT_WS('/', (SELECT name FROM pms_cbdl WHERE cbdl_code = SUBSTRING(t1.cbdl_code, 1, 1)), (SELECT name FROM pms_cbdl WHERE cbdl_code = t1.cbdl_code)) WHEN LENGTH(cbdl_code) = 4 THEN CONCAT_WS('/', (SELECT name FROM pms_cbdl WHERE cbdl_code = SUBSTRING(t1.cbdl_code, 1, 1)), (SELECT name FROM pms_cbdl WHERE cbdl_code = SUBSTRING(t1.cbdl_code, 1, 3)), (SELECT name FROM pms_cbdl WHERE cbdl_code = t1.cbdl_code)) WHEN LENGTH(cbdl_code) = 5 THEN CONCAT_WS('/', (SELECT name FROM pms_cbdl WHERE cbdl_code = SUBSTRING(t1.cbdl_code, 1, 1)), (SELECT name FROM pms_cbdl WHERE cbdl_code = SUBSTRING(t1.cbdl_code, 1, 3)), (SELECT name FROM pms_cbdl WHERE cbdl_code = SUBSTRING(t1.cbdl_code, 1, 4)), (SELECT name FROM pms_cbdl WHERE cbdl_code = t1.cbdl_code)) END AS new_name FROM pms_cbdl t1;以上语句执行报错
时间: 2024-04-15 22:24:51 浏览: 98
您好!根据您提供的SQL语句 SELECT cbdl_code, CASE WHEN LENGTH(cbdl_code) = 1 THEN name WHEN LENGTH(cbdl_code) = 3 THEN CONCAT_WS('/', (SELECT name FROM pms_cbdl WHERE cbdl_code = SUBSTRING(t1.cbdl_code, 1, 1)), (SELECT name FROM pms_cbdl WHERE cbdl_code = t1.cbdl_code)) WHEN LENGTH(cbdl_code) = 4 THEN CONCAT_WS('/', (SELECT name FROM pms_cbdl WHERE cbdl_code = SUBSTRING(t1.cbdl_code, 1, 1)), (SELECT name FROM pms_cbdl WHERE cbdl_code = SUBSTRING(t1.cbdl_code, 1, 3)), (SELECT name FROM pms_cbdl WHERE cbdl_code = t1.cbdl_code)) WHEN LENGTH(cbdl_code) = 5 THEN CONCAT_WS('/', (SELECT name FROM pms_cbdl WHERE cbdl_code = SUBSTRING(t1.cbdl_code, 1, 1)), (SELECT name FROM pms_cbdl WHERE cbdl_code = SUBSTRING(t1.cbdl_code, 1, 3)), (SELECT name FROM pms_cbdl WHERE cbdl_code = SUBSTRING(t1.cbdl_code, 1, 4)), (SELECT name FROM pms_cbdl WHERE cbdl_code = t1.cbdl_code)) END AS new_name FROM pms_cbdl t1; ,由于缺少表结构和完整的错误信息,无法准确判断报错原因。
请提供完整的错误信息,以及相关的表结构和数据,这样我才能更好地帮助您解决问题。谢谢!
阅读全文