DEV Community

Discussion on: SQL Practice Problem to Help You Pass Your Interview

Collapse
 
kamo profile image
KAIDI

Hey,
I think we can do this,

select  name, breed,adopted_on
from
dogs d inner join owners o on 
d.owner_id = o.id
where 
d.adopted_on >=
(
  select max(adopted_on) from dogs
  where d.owner_id = dogs.owner_id
)


`

Collapse
 
abdisalan_js profile image
Abdisalan

Very interesting! That works too!
I never thought to have another query in the where clause for comparison.

d.adopted_on >=
(
  select max(adopted_on) from dogs
  where d.owner_id = dogs.owner_id
)
Collapse
 
kamo profile image
KAIDI

Yeah, you can check the full syntax here
dev.mysql.com/doc/refman/8.0/en/se...