행복중입니다

[mariadb] 10.6 버전에 추가된 json_table 함수

· 2021-10-01 (금) 23:38:14 · 2674

10.6 버전에 새로 추가된 함수 같습니다.

개발할때 유용하게 사용할것 같아서

소개드립니다.

아시는분들은 아시겠지만 모르시는 분들을 위해서  정보 공유합니다.

활용 예1)

[code]

set @json='
[
  {"name":"Laptop", "color":"black", "price":"1000"},
  {"name":"Jeans",  "color":"blue"}
]';

select * from json_table(@json, '$[*]' 
  columns(
   name  varchar(10) path '$.name', 
   color varchar(10) path '$.color',
   price decimal(8,2) path '$.price' ) 
) as jt;

[/code]

 

활용 예2)

[code]

SELECT * FROM data_table t1, JSON_TABLE(
  t1.words, '$.123456.*' COLUMNS (word TEXT PATH '$')
) AS jt;

+------------------------------------------------------------------------------+-------+
| words                                                                        | word  |
+------------------------------------------------------------------------------+-------+
| {"123456":{"first":"hello","second":"there"}, "78910":{"first":"All good?"}} | hello |
| {"123456":{"first":"hello","second":"there"}, "78910":{"first":"All good?"}} | there |
+------------------------------------------------------------------------------+-------+

[/code]

 

참고링크 : https://mariadb.com/kb/en/json_table/

|
댓글을 작성하시려면 로그인이 필요합니다.

개발자팁

5,403건

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
PHP 19-06-24 조회 3,183
PHP 19-06-09 조회 3,807
MySQL 19-04-01 조회 4,856
jQuery 19-03-20 조회 4,240
node.js 19-02-12 조회 3,349
node.js 19-02-12 조회 3,079
node.js 19-02-12 조회 3,337
node.js 19-02-07 조회 3,319
node.js 19-02-07 조회 3,059
node.js 19-02-07 조회 3,208
node.js 19-02-04 조회 2,941
node.js 19-02-04 조회 2,914
node.js 19-02-04 조회 3,354
node.js 19-01-31 조회 2,474
node.js 19-01-31 조회 2,619
node.js 19-01-31 조회 3,099
node.js 19-01-28 조회 2,861
node.js 19-01-28 조회 2,945
node.js 19-01-28 조회 2,787
node.js 19-01-22 조회 3,114
node.js 19-01-22 조회 2,870
node.js 19-01-22 조회 3,300
node.js 19-01-16 조회 2,740
node.js
[node.js]
19-01-16 조회 2,640
node.js 19-01-16 조회 9,318
node.js 19-01-12 조회 4,400
node.js 19-01-12 조회 2,993
node.js 19-01-12 조회 3,136
node.js 19-01-11 조회 2,694
node.js 19-01-11 조회 4,045