목록MySQL (2)
HelloKoKo

실행 환경: MariaDB array 안에 object 형식으로 들어가 있는 경우 검색하는 방법이다. json_extract를 사용하여 height value 를 추출한후 json_search를 통해서 검색 해내는 방법이다. SET @json_document = '{ "name": "ab", "specs": [{ "weight": 10, "height": "as" }, { "weight": 101, "height": "as1" }] }'; SELECT JSON_SEARCH(JSON_EXTRACT(@json_document, '$.specs[*].height'), 'all', "as") is not null; 결과 결과 값이 있을 경우 1, 없을 경우 0으로 검색 된다.
http://sqlfiddle.com/ SQL Fiddle | A tool for easy online testing and sharing of database problems and their solutions. Query Panel Use this panel to try to solve the problem with other SQL statements (SELECTs, etc...). Results will be displayed below. Share your queries by copying and pasting the URL that is generated after each run. sqlfiddle.com https://sqltest.net/ SQL Test Free Online SQL T..