I have an item table where there is a type column. The values here can be 1, 2, 3, or 0. users have a predefined value, but 0 acts as a global – all users get these items returned.
The main caveat is that an item could be a 3, but also have a 0 record as well, meaning the 3s get one record, the 1s and 2s get the 0 record.
My question is how do i write the query so the 3s don’t also get the 0 record?
To keep your query simple, you can fetch both records, order them by type, descending, then only take the first one: