Skip to content

Instantly share code, notes, and snippets.

@mikedfunk
Created December 1, 2011 03:41
Show Gist options
  • Save mikedfunk/1413346 to your computer and use it in GitHub Desktop.
Save mikedfunk/1413346 to your computer and use it in GitHub Desktop.
SELECT `bt_accounts`.`id`, `bt_payments`.`id`, `bt_payments`.`amount`, `bt_payments`.`date`, `bt_users`.`first_name`, `bt_users`.`last_name`
FROM (`bt_accounts`)
LEFT JOIN `bt_payments` ON `bt_payments`.`account_id` = `bt_accounts`.`id`
LEFT JOIN `bt_salespeople` ON `bt_salespeople`.`id` = `bt_accounts`.`salesperson_id`
LEFT JOIN `bt_users` ON `bt_users`.`salesperson_id` = `bt_salespeople`.`id`
ORDER BY `bt_payments`.`id` desc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment