class Customer < ActiveRecord::Base
has_one :address, :foreign_key => "customerid"
end
class Address < ActiveRecord::Base
belongs_to :customer, :foreign_key => "customerid"
end
如何在地址表中找到客户中没有customerid的记录?
SQL中的我会做
select * from customer a, address b where a.customerid <> b.customerid
答案 0 :(得分:0)
这将返回没有customers
的<{1}}:
address
希望我能正确理解你的问题。