If I query certain data in a query where in
, it would bring back the matching data.
- Example: http://rextester.com/OZJX17754
But my question is how do I get the data that does not match and throw it in the query?
"Data to consult" is a random list, it is not a table, and of these data that I want to consult, I am not interested in those that are already there, but rather those that are not.
In order to select the rows of numbers you want, they first... well... have to be in a table.
DATOS A CONSULTAR
it should be a table within the database.If the values are used only for a casual query (or if they are generated from another script), a temporary table can be generated.
Allowing to use them as a result of the query. We could use
NOT IN
, but I prefer to useNOT EXISTS
(which is more efficient if the column is nullable).A possible alternative to what Mariano recommends (I personally would opt for that) could be to create the temporary table on the fly , using the function
regexp_split_to_table
and passing the values to it as a string. You would still have a temporary table, but it would be somewhat closer to what you seem to be looking for.The code would look something like this (you can see it running on this Rextester ):