Hello


Are you still looking for a query?

SELECT studentID, name, address, cityID
FROM Student, City
WHERE address LIKE CONCAT('%', city, '%')
ORDER BY studentID

In this case, you don’t see the students with no matching cityID.

With the following query the same result.

SELECT studentID, name, address, cityID
FROM Student
INNER JOIN City
ON address LIKE CONCAT('%', city, '%')
ORDER BY studentID

When you still want to see all the students, also with no cityID, change INNER into LEFT.

SELECT studentID, name, address, cityID
FROM Student
LEFT JOIN City
ON address LIKE CONCAT('%', city, '%')
ORDER BY studentID

If address always begin with city then you can change CONCAT('%', city, '%') into CONCAT(city, '%')

I hope this will help you.