How can I make this query into a scope in rails 3.2?
The point is to access two different table entries and pick info that is common to both of them.
SELECT u1.FirstName, u2.FirstName
FROM User AS u1, User AS u2
WHERE u2.LastName=u1.LastName
Do you know other way to achieve this with better performance?
Cheers
Assuming I understand your question, you can do this:
This will give you all the users that have the same last name as any other user.