Created
March 8, 2017 15:21
-
-
Save thomasem/8649f8e0b07573cfb82975fba2930fd9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql> show columns from variables; | |
+----------------+--------------+------+-----+---------+-------+ | |
| Field | Type | Null | Key | Default | Extra | | |
+----------------+--------------+------+-----+---------+-------+ | |
| created_at | datetime | YES | | NULL | | | |
| updated_at | datetime | YES | | NULL | | | |
| association_id | int(11) | NO | PRI | NULL | | | |
| key_ | varchar(255) | NO | PRI | NULL | | | |
| value_ | json | YES | | NULL | | | |
+----------------+--------------+------+-----+---------+-------+ | |
5 rows in set (0.00 sec) | |
mysql> SELECT JSON_EXTRACT(value_, '$') FROM variables; | |
+-------------------------------+ | |
| JSON_EXTRACT(value_, '$') | | |
+-------------------------------+ | |
| "juno" | | |
| "swift" | | |
| true | | |
| "novnc" | | |
| "192.168.1.0/22" | | |
| "flavor_classes=performance2" | | |
| "10.10.1.100" | | |
| "flavor_classes=performance1" | | |
| "10.20.1.100" | | |
| "swift" | | |
| true | | |
| "novnc" | | |
| "192.168.4.0/22" | | |
| "flavor_classes=performance2" | | |
| "10.10.1.100" | | |
| "flavor_classes=performance1" | | |
| "10.20.1.100" | | |
| "kilo" | | |
| "swift" | | |
| true | | |
| "novnc" | | |
| "192.168.1.0/22" | | |
| "flavor_classes=performance2" | | |
| "10.10.1.100" | | |
| "flavor_classes=performance1" | | |
| "10.20.1.100" | | |
| "swift" | | |
| true | | |
| "novnc" | | |
| "192.168.4.0/22" | | |
| "flavor_classes=performance2" | | |
| "10.10.1.100" | | |
| "flavor_classes=performance1" | | |
| "10.20.1.100" | | |
| {"json": "definitely"} | | |
| "non-json" | | |
+-------------------------------+ | |
36 rows in set (0.00 sec) | |
mysql> SELECT * FROM variables WHERE JSON_CONTAINS(JSON_EXTRACT(value_, '$'), '"non-json"'); | |
+---------------------+---------------------+----------------+---------------+------------+ | |
| created_at | updated_at | association_id | key_ | value_ | | |
+---------------------+---------------------+----------------+---------------+------------+ | |
| 2017-03-08 15:12:49 | 2017-03-08 15:12:49 | 85 | test-non-json | "non-json" | | |
+---------------------+---------------------+----------------+---------------+------------+ | |
1 row in set (0.00 sec) | |
mysql> SELECT * FROM variables WHERE JSON_CONTAINS(JSON_EXTRACT(value_, '$.json'), '"definitely"'); | |
+---------------------+---------------------+----------------+-----------+------------------------+ | |
| created_at | updated_at | association_id | key_ | value_ | | |
+---------------------+---------------------+----------------+-----------+------------------------+ | |
| 2017-03-08 15:16:39 | 2017-03-08 15:16:39 | 85 | test-json | {"json": "definitely"} | | |
+---------------------+---------------------+----------------+-----------+------------------------+ | |
1 row in set (0.00 sec) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment