Which records aren't in list? Use static list as table or records

Поиск
Список
Период
Сортировка
От Durumdara
Тема Which records aren't in list? Use static list as table or records
Дата
Msg-id CAEcMXhnOgYBB9JznjwVLX2XVL3+LZegZGcNGSVVWP=CMzvpgag@mail.gmail.com
обсуждение исходный текст
Ответы SV: Which records aren't in list? Use static list as table orrecords  (Gustavsson Mikael <mikael.gustavsson@smhi.se>)
RE: Which records aren't in list? Use static list as table or records  (Patrick FICHE <Patrick.Fiche@aqsacom.com>)
Список pgsql-general
Hi!

A very silly question. I have a limited list of identifiers.
I want to know which one IS NOT in a table.

The
select * from theserecords where id not in (1, 5, 12, 33, 55)
isn't listing missing records... because they are missing... :-)

For example, a pseudo:
idlist = (1, 5, 12, 33, 55)
select id from idlist
where id not in (select id from theserecords)

The id list is a static string.

Now I can do this with temporary table - I create one, insert the ID-s and run the select:

select id from temptable where id not in (select id from theserecords)

It would be nice if I can get the missing ID-s.

F.e:

select id from (
   select 1 as id, 
   select 5 as id,   
   ...
) where id not in (select id from theserecords)

or

select id from (
  select split_string_to_records('1,2,3,4,5', ',') as id
) ...

Do you know any simple way to do this without stored proc or temp table?

Thank you!

B.W:
    dd

В списке pgsql-general по дате отправления:

Предыдущее
От: Rob Sargent
Дата:
Сообщение: Re: how to write correctly this update ?
Следующее
От: Gustavsson Mikael
Дата:
Сообщение: SV: Which records aren't in list? Use static list as table orrecords