sql查询将一列拆分为两列

rdrgkggo  于 2021-06-25  发布在  Mysql
关注(0)|答案(0)|浏览(242)
select ClientID,  
case 
when locate('Rate-Limit',CurrentAttributes) > 0 then substring_index(substring_in)

输出中将有三列,“clientid”、“attribute”和“value”。
我想出了这个办法,但不适合我。
在clients表中,“currenttributes”可以有多个用分号分隔的属性/值对。这些对将有一个属性,一个等号,后跟一个值。 (For example in "framed-ip-address=192.168.68.5", 'framed-ip-address' will be the attribute and '192.168.68.5' will be the value) .
当列中有多个属性/值对时,必须为每对输出另一行。例如,如果clientid为“1111”的行具有“rate limit=9216k/9216k 9216k/9216k 9216k/9216k 120/120\n帧ip地址=192.168.68.5;”在“currentattributes”列中,我将查找输出两行的查询
第一行:

ClientID:1111
attribute:Rate-Limit
value:9216k/9216k 9216k/9216k 9216k/9216k 120/120

第二排:

ClientID:1111
attribute:framed-ip-address
value:192.168.68.5

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题