행복중입니다

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

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

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,209
PHP 19-06-09 조회 3,826
MySQL 19-04-01 조회 4,881
jQuery 19-03-20 조회 4,269
node.js 19-02-12 조회 3,370
node.js 19-02-12 조회 3,110
node.js 19-02-12 조회 3,369
node.js 19-02-07 조회 3,343
node.js 19-02-07 조회 3,086
node.js 19-02-07 조회 3,223
node.js 19-02-04 조회 2,968
node.js 19-02-04 조회 2,941
node.js 19-02-04 조회 3,385
node.js 19-01-31 조회 2,492
node.js 19-01-31 조회 2,649
node.js 19-01-31 조회 3,119
node.js 19-01-28 조회 2,890
node.js 19-01-28 조회 2,974
node.js 19-01-28 조회 2,809
node.js 19-01-22 조회 3,148
node.js 19-01-22 조회 2,899
node.js 19-01-22 조회 3,357
node.js 19-01-16 조회 2,772
node.js
[node.js]
19-01-16 조회 2,670
node.js 19-01-16 조회 9,346
node.js 19-01-12 조회 4,422
node.js 19-01-12 조회 3,020
node.js 19-01-12 조회 3,165
node.js 19-01-11 조회 2,715
node.js 19-01-11 조회 4,069