Welcome Guest, Not a member yet? Register   Sign In
Can I make this query using the active record class?

I was using the active record class until I had to add a sub query.

Here's my query:

SELECT job_id, jobs.user_id, title, description, commission_min, commission_max, skills, post_date, upgrade_border, upgrade_highlight, profiles.display_name, COALESCE(avg_score, 0) as avg_score
FROM jobs
JOIN profiles ON(jobs.user_id = profiles.user_id)
JOIN job_categories ON(jobs.cat_id = job_categories.cat_id)
JOIN job_sub_categories ON(jobs.sub_cat_id = job_sub_categories.sub_cat_id)
LEFT OUTER JOIN (SELECT employer_id, AVG((performance + quality + availability + communication)/4) AS avg_score
    FROM feedback GROUP BY employer_id) AS sq
    ON(jobs.user_id = sq.employer_id)
WHERE status = 'open'

Thanks for any help!

Theme © iAndrew 2016 - Forum software by © MyBB