I have a JSON field in a MySQL database that contains values like [1,3,4,7]. I would like to be able to easily supply another array from a PHP variable and determine if there is any overlap. I know this example does not work, but this is what I am trying to do:
$DaysVar = $_GET['Days']; --Example is [1,5,8]
$sql = mysqli_query($db, "
SELECT ScheduleID,
Days --Example is [1,3,4,7]
FROM Schedule
WHERE JSON_CONTAINS(Days, '$DaysVar')
");
How can I get this query to return a result since there is a 1 in each array?


JSON_CONTAINSonly available in 5.7.8 or later