0
I need to verify which Ids were not found in the table.
SELECT * FROM example_table WHERE id IN (123, 124, 125, 126, 127)
Whereas of (123, 124, 125, 126, 127)
, on the table I only have (123, 124)
.
The result I’m waiting for is (125, 126, 127)
.
I’ve explored the Sub-Querys option but I can’t figure out how to end it.
The idea was to do all this in a Mysql query. But the language is C#.
– zakharuk_pasha
There has to be some way out that allows me to put the "list" of values and receive which of these values is not in the table.
– zakharuk_pasha
All the times I had to do it. I created a table and populated with all the values, so I can select all the items in this table that do not have in the other.
– Reginaldo Rigo
For Sqlite I have this solution. SELECT A.X FROM ( WITH RECURSIVE cnt(X) AS (VALUES(123) UNION ALL SELECT X+1 FROM cnt WHERE X < (127)) SELECT X FROM cnt ) A LEFT JOIN ( SELECT CAST( id AS NUMBER ) AS id FROM example_table WHERE id >= 123 and ID <= 127 ) B ON A.X = B.id WHERE B.id IS NULL LIMIT ( 123 - 127 + 1 )
– Reginaldo Rigo
@Reginaldorigo depending on the version of
MySql
is just like that, the Mysql 8.0 supports CTE– Diego Rafael Souza