Welcome Guest, Not a member yet? Register   Sign In
SQL optimization via Active Record
#1

[eluser]taewoo[/eluser]
Hi everyone.

I am writing a standard user-to-user messaging application.
So every time someone sends or receives a message from another user, I'd have to query the USERS table to get their username, first name, last name, picture, etc.

To make it more efficient, I was thinking of doing something like (in pseudo-code):

Code:
select USER_NAME, FIRST_NAME, LAST_NAME, PICTURE from USERS where USERS.id IN ((select ID from senders) UNION (SELECT ID from recipients));

Is there a way to do this w/Active Record or do I need to spell it out w/raw SQL? Particularly the "in" comparison operator... is there a documentation for this?


Messages In This Thread
SQL optimization via Active Record - by El Forum - 02-02-2008, 02:19 PM
SQL optimization via Active Record - by El Forum - 02-02-2008, 02:34 PM
SQL optimization via Active Record - by El Forum - 02-02-2008, 04:15 PM
SQL optimization via Active Record - by El Forum - 02-03-2008, 03:01 AM



Theme © iAndrew 2016 - Forum software by © MyBB