I have the following query:
SELECT "emails".id, "emails".message_id, subject, body, html, sent_at,
t1.message_count
FROM "emails"
INNER JOIN "email_participants"
ON ("email_participants"."email_id" = "emails"."id")
LEFT JOIN (
SELECT COUNT(*) message_count, message_id
FROM replies
GROUP BY message_id) t1
ON "emails".message_id = t1.message_id
WHERE (("user_id" = 163) AND ("folder" = 'INBOX')
AND ("emails".id NOT IN (SELECT email_id FROM Replies)))
ORDER BY "sent_at" DESC LIMIT 100 OFFSET 0;
I can handle everything apart from the derived table join, I could create a
view but is it possible to join on a derived table with the sequel gem?
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.