Hello, I have the following code which needs to use WHERE NOT EXISTS. Can I somehow use ORM to structure this or am I stuck using raw sql ?
// Return all non-deleted radiation machine locations where an active, operator does not exist
// Return all non-deleted radiation machine locations where an active, operator does not exist
Code:
SELECT * FROM radiation_machine_location WHERE NOT EXISTS ( SELECT * FROM radiation_machine_operator_radiation_machine_location INNER JOIN radiation_machine_operator ON radiation_machine_operator.id = radiation_machine_operator_radiation_machine_location.radiation_machine_operator_id WHERE radiation_machine_operator.status = 'ACTIVE' AND radiation_machine_operator_radiation_machine_location.radiation_machine_location_id = radiation_machine_location.id AND radiation_machine_operator.deleted = 0 ) AND radiation_machine_location.deleted = 0
Comment