How to only select rows with no children?

Hi. I have a model that can have children (one-to-many relationship to a different model) and I would like to find all rows that have no children. Is there a way to do it without writing raw SQL?

Thank you!

You might be able to use a LEFT JOIN to do this - see Need SQL Query to find Parent records without child records - Stack Overflow

1 Like