I have a separate table of Cities that have city codes in them and I also have a main table that contains a column 'address' which is only a short address. What I want is to select the city with code that is similar to the data in the 'address' column.
$cityCode=$db->query("SELECT city AS bot FROM city_table WHERE city LIKE (SELECT address FROM people WHERE people_id = $zz)");
$cityCode=$cityCode->num_rows > 0 ? $cityCode->fetch_array()['bot'] : "NOT LIKE";
city_table:
| province | city |
| ----------------------- | ------------------------ |
| ILOCOS NORTE/012800000 | CITY OF BATAC/012805000 |
people:
| people_id | address |
| ----------------------- | ------------------------ |
| 1 | P-2, Brgy. 20, Batac City|
If the address contains "Batac", I want to echo it as 'CITY OF BATAC/012805000'
How to make this work?