Обсуждение: select all rows where any column is NULL

Поиск
Список
Период
Сортировка

select all rows where any column is NULL

От
Nathan Boley
Дата:
Does anyone have a concise way of doing $SUBJECT?

Best,
Nathan

Re: select all rows where any column is NULL

От
"David Johnston"
Дата:
Copy and paste the column names from the "CREATE TABLE" statement...

You can try using information schema and building a dynamic SQL query inside
a function...

If you let people know WHAT you are trying to accomplish you may find you
get alternative suggestions that you never considered.

SQL itself is designed for a variable/unknown numbers of rows but a
fixed/known number of columns.  The only way around that is to use a "table
of column names" to identify the columns and then dynamically create a query
with those "fixed/known" columns and "EXECUTE" it within a PL/PGSQL
function.

David J.

-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org] On Behalf Of Nathan Boley
Sent: Tuesday, July 26, 2011 3:09 PM
To: PostgreSQL general
Subject: [GENERAL] select all rows where any column is NULL

Does anyone have a concise way of doing $SUBJECT?

Best,
Nathan

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make
changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: select all rows where any column is NULL

От
Merlin Moncure
Дата:
On Tue, Jul 26, 2011 at 2:08 PM, Nathan Boley <npboley@gmail.com> wrote:
> Does anyone have a concise way of doing $SUBJECT?

 select * from foo where (row((foo).*) = row((foo).*)) is null;

merlin