We are used to issue queries with an IN clause of the form:
... where state in ('started', 'completed', 'failed') ...
However I've had a few cases where I used an inverted format. Here's one use case followed by an inverted IN clause.
Dynamic query building
Say we have this function:
Which, based on whether given clusterName is empty or not, would return list of all lagging slaves, or only those in the given cluster, respectively:
SELECT hostname FROM database_instance WHERE slave_lag_seconds > …[Read more...]