/ Published in: SQL
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
SELECT users.id, users.sage_username, users.email, organizations.id, organizations.name, user_gateways.gateway_name, user_gateways.merchant_id, user_gateways.merchant_key, user_gateways.login, user_gateways.email, user_gateways.active, user_gateways.type FROM organizations JOIN users ON organizations.created_by_id = users.id JOIN user_gateways ON user_gateways.organization_id=organizations.id JOIN (SELECT organization_id, gateway_name, COUNT(gateway_name) FROM user_gateways GROUP BY organization_id, gateway_name HAVING COUNT(gateway_name) > 1) AS them ON them.organization_id = organizations.id;