MySQL method to extract all keys in nested JSON string
P粉257342166
P粉257342166 2023-08-28 14:17:16
0
1
457
<p>In addition to this answer, is it possible to extract nested keys in a simple way? Example: </p> <pre class="brush:php;toolbar:false;">{ "a": value, "b": { "c": value, "d": { "e": value } } }</pre> <p>Desired output: ['a', 'b.c', 'b.d.e'] What I've tried: </p> <pre class="brush:php;toolbar:false;">SELECT f.`id` AS `field_name` FROM table t, JSON_TABLE( JSON_KEYS(t.`column`, '$.b'), '$[*]' COLUMNS( `id` VARCHAR(191) PATH '$' ) ) AS t</pre> <p>But this will only show one of the nested keys and skip the outer keys. </p>
P粉257342166
P粉257342166

reply all(1)
P粉009186469

db<>fiddle here

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!