I'm trying to find the items in a list that are not present in a table in sqlite. So, I created a temporary database in memory and created a table in that new database where I inserted all the elements from the list. Then I did a count on the list to make sure everything was there, and it was:
sqlite> SELECT DISTINCT COUNT(*) FROM tempDB.SERVICERUN;
4894
Then I selected everything in my original table using the new table:
sqlite> SELECT COUNT(ZGUID) FROM ZWVSERVICERUN WHERE ZGUID IN (SELECT GUID FROM tempDB.SERVICERUN);
4889
Then when I try to select the items in the new table using the previous result, I get nothing:
sqlite> SELECT * FROM tempDB.SERVICERUN WHERE GUID NOT IN (SELECT ZGUID FROM ZWVSERVICERUN WHERE ZGUID IN (SELECT GUID FROM tempDB.SERVICERUN));
This seems impossible to me, since in my first query, I select only distinct items and there are 4894 items. Then when I use those to select from the original table, I only get 4889 items. So it seems like there are 5 items that are in the new table and not the original. If anybody has any insight into this problem, I would really appreciate your help.
On a side note:
I also tried a left join and still got nothing:
sqlite> SELECT tempDB.SERVICERUN.GUID FROM tempDB.SERVICERUN LEFT JOIN ZWVSERVICERUN ON ZWVSERVICERUN.ZGUID = tempDB.SERVICERUN.GUID WHERE ZWVSERVICERUN.ZGUID IS NULL;
Aucun commentaire:
Enregistrer un commentaire