Welcome Guest, Not a member yet? Register   Sign In
Field names with JOIN queries
#3

[eluser]deed02392[/eluser]
Well that is one solution, but I thought the point of using activerecord was to maintain portability of queries? Of course your solution is only applicable to MySQL.

If I was doing it as a raw query I'd do:

Code:
SELECT u.id, u.username, c.name FROM users AS u JOIN companies AS c ON c.id = u.company_id WHERE u.username = 'foobar';

Which is great but if I tried to do that in active record I reckon that's pretty poor practice, if it works at all.


Messages In This Thread
Field names with JOIN queries - by El Forum - 04-06-2012, 07:49 AM
Field names with JOIN queries - by El Forum - 04-06-2012, 09:17 AM
Field names with JOIN queries - by El Forum - 04-06-2012, 09:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB