Category:Computer science booksQ:
Mysql select statement for this scenario
I have a table containing data similar to the below:
Id Name Code
1 Teacher1 12345
2 Teacher2 12346
3 Teacher3 12347
4 Teacher4 12348
5 Teacher5 12349
6 Teacher6 12350
7 Teacher7 12351
I want to get a result which consists of id, name and code for only the teachers who are registered at that same address as the one where query is executed.
eg.
id name code
2 Teacher2 12346
4 Teacher4 12348
5 Teacher5 12349
7 Teacher7 12351
How do I write a query for this?
A:
Try this query:
SELECT *
FROM tbl
WHERE code IN (SELECT code
FROM tbl
WHERE id = be359ba680
Related links:
Comentarios