MySQL 8.0.17 adds three new functions to the JSON
repertoire. All three can take advantage of the new
Multi-Value Index feature or can be used on JSON arrays.
JSON_CONTAINS(target, candiate[,
path])
This function indicates with a 1 or 0 if a candidate
document is contained in the target document. The optional
path argument lets you seek information in embedded
documents. And please note the 'haystack' is before the
'needle' for this function.
mysql> SELECT JSON_CONTAINS('{"Moe": 1, "Larry":
2}','{"Moe": 1}');
+------------------------------------------------------+
| JSON_CONTAINS('{"Moe": 1, "Larry": 2}','{"Moe": 1}') |
+------------------------------------------------------+
…
Showing entries 1 to 1
Jul
22
2019
Showing entries 1 to 1