select substring_index(NAME,‘|’,2) from tb_game_setting_pk;

select * from tb_game_setting_pk t where t.lot_name = ‘北京赛车’;

SELECT id,
SUBSTRING_INDEX(SUBSTRING_INDEX(NAME, ‘|’, n), ‘|’, -1) AS item
FROM tb_game_setting_pk,
(SELECT @rownum := @rownum + 1 AS n
FROM (SELECT @rownum := 0) r,
tb_game_setting_pk) x
WHERE n <= (LENGTH(NAME) – LENGTH(REPLACE(NAME, ‘|’, ‘’)) + 1) and lot_name = ‘北京赛车’ order by item;

select group_concat(item) from (
SELECT id,
SUBSTRING_INDEX(SUBSTRING_INDEX(NAME, ‘|’, n), ‘|’, -1) AS item
FROM tb_game_setting_pk,
(SELECT @rownum := @rownum + 1 AS n
FROM (SELECT @rownum := 0) r,
tb_game_setting_pk) x
WHERE n <= (LENGTH(NAME) – LENGTH(REPLACE(NAME, ‘|’, ‘’)) + 1) and lot_name = ‘北京赛车’ order by item

) a ;

select b.lot_name, GROUP_CONCAT(b.item) from (
SELECT lot_name,
SUBSTRING_INDEX(SUBSTRING_INDEX(NAME, ‘|’, n), ‘|’, -1) AS item
FROM tb_game_setting_pk,
(SELECT @rownum := @rownum + 1 AS n
FROM (SELECT @rownum := 0) r,
tb_game_setting_pk) X
WHERE n <= (LENGTH(NAME) – LENGTH(REPLACE(NAME, ‘|’, ‘’)) + 1) ORDER BY lot_name, item
) b group by b.lot_name ;

SELECT aa.lot_name,bb.item FROM tb_game_setting_pk aa,
( SELECT b.lot_name, GROUP_CONCAT(b.item) item FROM (
SELECT lot_name,
SUBSTRING_INDEX(SUBSTRING_INDEX(NAME, ‘|’, n), ‘|’, -1) AS item
FROM tb_game_setting_pk,
(SELECT @rownum := @rownum + 1 AS n
FROM (SELECT @rownum := 0) r,
tb_game_setting_pk) X
WHERE n <= (LENGTH(NAME) – LENGTH(REPLACE(NAME, ‘|’, ‘’)) + 1) ORDER BY lot_name, item
) b GROUP BY b.lot_name
) bb WHERE aa.lot_name = bb.lot_name ;