一个草稿对对对
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 ;
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!