Skip to content

Instantly share code, notes, and snippets.

@stajkowski
Created January 29, 2016 16:38
Show Gist options
  • Save stajkowski/a7e58ffdc9c1f4c38162 to your computer and use it in GitHub Desktop.
Save stajkowski/a7e58ffdc9c1f4c38162 to your computer and use it in GitHub Desktop.
query
SELECT quark_mac_address_ranges.id AS quark_mac_address_ranges_id, quark_mac_address_ranges.created_at AS quark_mac_address_ranges_created_at, quark_mac_address_ranges.cidr AS quark_mac_address_ranges_cidr, quark_mac_address_ranges.first_address AS quark_mac_address_ranges_first_address, quark_mac_address_ranges.last_address AS quark_mac_address_ranges_last_address, quark_mac_address_ranges.next_auto_assign_mac AS quark_mac_address_ranges_next_auto_assign_mac, quark_mac_address_ranges.do_not_use AS quark_mac_address_ranges_do_not_use, count(quark_mac_addresses.address) AS count
FROM quark_mac_address_ranges LEFT OUTER JOIN quark_mac_addresses ON quark_mac_address_ranges.id = quark_mac_addresses.mac_address_range_id
WHERE quark_mac_address_ranges.next_auto_assign_mac != %s AND quark_mac_address_ranges.do_not_use = %s GROUP BY quark_mac_address_ranges.id ORDER BY count(quark_mac_addresses.address) DESC
LIMIT %s FOR UPDATE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment