After using the CONCAT statement, data cannot be queried. The execution plan shows it is treated as a single string. How to handle this situation?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 使用concat语句以后数据查询不出来,看执行计划是当成一个字符串处理了,这种情况下怎么操作

| username: TiDBer_s7AnS8qP


| username: tidb菜鸟一只 | Original post link

Change “in” to this:

SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(a.name,'|',b.help_topic_id+1),'|',-1) AS NAME
FROM (SELECT '76736850|15007442|90004909|90003852|90009555|90004922' NAME ) a,
(SELECT 0 help_topic_id UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6) b
WHERE b.help_topic_id < (LENGTH(a.name)-LENGTH(REPLACE(a.name,'|',''))+1);
| username: 林夕一指 | Original post link

Why would this be handled by the database? :rofl:

| username: Kongdom | Original post link

We usually concatenate this in the program, so there’s no need to concatenate it when the database executes.