Let’s say you’ve got three tables, Cars, Makes, Models. What if you need to get a list of cars including their Make and Model?
Here’s where subselects come in.
And here’s the query:
(select name from makes where id = c.makeid) as make,
m.model as model
from cars c
inner join models as m on c.modelid = m.id