If I do the following query:
select * from tabla where codigo in (33,34,55,10,22,50);
msyql shows me the records that match the query.
But what if I want to know what records from this query (33,34,55,10,22,50) which are not in the database?
Is there any way to know that without having to compare one record per one by myself?
Excuse me, I din’t explain it well. This shows me the records which are in the database but don’t match the query. I want to know what of this records (33,34,55,10,22,50) are not in the database.
Use NOT:
UPDATE
In light of this new explanation, do this:
Unfortunately, MySQL (and many other systems) don’t give a simple way to use an arbitrary list of numbers that aren’t already in some table. If you need to do this dynamically, I would suggest adding these numbers to a temp table in place of a hard-coded batch of UNIONs. Or generate a reusable numbers table (I find this fairly useful), and use the values from there. For example: