如何使用匹配的字符串过滤sql查询结果

I have a database table in which one column contain the string value that is looks like dictionary in php.

Table:College

Id  name    requirement
1   x   {"users": ["A", "B"], "name": "*", "pool": "CSE", "place": "Bangalore"}
2   y   {"users": ["A", "C"], "name": "*", "pool": "CSE", "place": "Chennai"}
3   z   {"users": ["A", "B"], "name": "*", "pool": "ECE", "place": "Bangalore"}
4   r   {"users": ["A", "D"], "name": "*", "pool": "EEE", "place": "UP"}

From this table I need to filter only those rows in which the requirements column contain “pool”:”CSE”. That is if pool is CSE or pool is ECE etc .

Currently my php code for fetching whole table is:

    $query = "SELECT * FROM waitqueue";
    $result = mysql_query($query);

    echo "[";
    echo json_encode(mysql_fetch_assoc($result));
    while ($row = mysql_fetch_assoc($result))
        echo "," . json_encode($row);
    echo "]";

I dont want to change the above sql query.Because I need both conditions(full table and selected pool rows) from single query.So I wish to parse from results.

How to match the "pool" and how can I filter those rows?

Any one please suggest me.

Thanks in advance.

In your case you can filter like this

WHERE requirement LIKE '%"pool": "CSE"%'

But this is very big crutch :)

It is prefer to separate column requirement to columns: name, pool, place. Than you may filter like this, for example:

WHERE pool = "CSE"

Other method is to filter rows in your while cycle like this

$output = '';
while ($row = mysql_fetch_assoc($result)) {
    $requirement = json_decode($row['requirement'], true);
    if ($requirement['pool'] === 'CSE') {
        $output .= $output ? ', ' : '';
        $output .= json_encode($row);
    }
}
$output = '[' . $output . ']';
echo $output;