How can specific integer values within a serialized array be queried in a SELECT statement in PHP?

To query specific integer values within a serialized array in a SELECT statement in PHP, you can use the LIKE operator along with the % wildcard to search for the integer value within the serialized array string. You can also unserialize the array data and then use PHP functions to access specific integer values within the array.

// Assume $serializedArray contains the serialized array data
$specificValue = 123; // Integer value to query

// Query to retrieve rows where the specific integer value exists within the serialized array
$query = "SELECT * FROM table_name WHERE serialized_column LIKE '%\"$specificValue\"%'";
$result = mysqli_query($connection, $query);

// Loop through the result set
while($row = mysqli_fetch_assoc($result)) {
    $unserializedArray = unserialize($row['serialized_column']);
    // Access specific integer values within the unserialized array
    echo $unserializedArray[$specificValue];
}