Created
July 29, 2014 21:33
-
-
Save spotco/5773bdee2f5d19af9da0 to your computer and use it in GitHub Desktop.
lelquery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rtv = ActiveRecord::Base.connection.execute(" | |
| (SELECT pending_participant.first_name AS first_name, pending_participant.last_name AS last_name, pending_participant.email AS email, 'Pending' as status | |
| FROM sdo_pending_participants AS pending_participant | |
| WHERE pending_participant.sdo_turnkey_project_id = 2443) | |
| UNION | |
| (SELECT DISTINCT participant.first_name AS first_name, participant.last_name AS last_name, participant_email_address.email_address AS email, participant_project.status as status | |
| FROM participants AS participant | |
| JOIN participant_email_addresses AS participant_email_address ON participant_email_address.id = (SELECT id FROM participant_email_addresses AS participant_email_addresses_first WHERE participant_email_addresses_first.participant_id = participant.id LIMIT 1) | |
| JOIN participant_projects AS participant_project ON participant_project.participant_id = participant.id | |
| JOIN projects AS project ON project.id = participant_project.project_id | |
| JOIN sdo_turnkey_projects AS sdo_turnkey_project ON sdo_turnkey_project.project_id = project.id | |
| WHERE sdo_turnkey_project.id = 2443 ) | |
| ").each { |i| puts i } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment