SyntaxFix
Write A Post
Hire A Developer
Questions
You have to self join stuff and match name and city. Then group by count.
select s.id, s.name, s.city from stuff s join stuff p ON ( s.name = p.city OR s.city = p.name ) group by s.name having count(s.name) > 1