Multiple table SQL query in rails?

Table A has many table B’s. So the foreign key in table B is a_id. I
want to select a single record from table A that does not have any
table B’s. The problem is that the foreign key is in table B. Is
there a simple way to do this with the find method in active record?
Or do I need to select all and loop through them all and check until
I find one?

Thanks for your help.

Thank You,
Ben J.

If you want to find all records in a which have no record in b…

A.find( :all, :include => :b, :conditions => ‘b.id IS NULL’ )

If you want to select a certain one, just add additional conditions as
you
see fit.

mark