I have a table containing values like the following:
"things"
+ FirstOctet + SecondOctet +
| 0          | 0           |
| 0          | 1           |
| 1          | 0           |
| 1          | 0           |
+------------+-------------+
Essentially, FirstOctet and SecondOctet contain values that range form 0-255. The rows are in no particular order. I want to query the database to get the next available value within the table, based on the lowest FirstOctet and SecondOctet. There are no duplicate values for FirstOctet AND SecondOctet (if that makes sense).
So, if the table looks something like:
"things"
+ FirstOctet + SecondOctet +
| 1          | 0           |
| 1          | 4           |
| 1          | 1           |
| 1          | 3           |
+------------+-------------+
I'd like it to find that the next available values are FirstOctet=1 and SecondOctet=2.
All I have so far is just a pretty simple query to tally up the first octets, and that have a count under 255.
select 
    *, count(*) as count
from
    things
group by first_octet
having count < 255
order by first_octet
I have no idea where to go from here. I'm thinking that once I find rows where FirstOctet < 255, it MUST have an available row. Where do I go from here?
 
    