[eluser]skunkbad[/eluser]
My knowledge of complex MySQL is not as robust as I'd like it to be, but I've got a working query, and wondering if I can recreate it with Active Record, or what the best way to run it would be. The query simply checks if there is a record in table1 that hasn't been applied to a field in table2. I've simplified the table names and fields to make it easier to see:
Code:
SELECT table1.*,
IF( COUNT( table2.something ) > 0, "false", "true" )
AS "unassigned"
FROM table1
LEFT JOIN table2
ON table1.whatever = table2.something
GROUP BY table1.whatever
No data will be passed to the query, so it's not necessary to worry about escaping anything. I'd just like to know if I can use active record or not.