有许多略有相似的问题,但没有一个能解决这个问题." 在任何列中查找具有空值的所有行 "是我能找到的最接近的一个并为SQL Server提供答案,但我正在寻找一种在PostgreSQL中执行此操作的方法.
如何只选择任何列中具有NULL值的行?
我可以轻松地获得所有列名称:
select column_name from information_schema.columns where table_name = 'A';
Run Code Online (Sandbox Code Playgroud)
但目前还不清楚如何检查多个列名称的NULL值.显然这不起作用:
select* from A where (
select column_name from information_schema.columns where table_name = 'A';
) IS NULL;
Run Code Online (Sandbox Code Playgroud)
并且搜索没有发现任何有用的东西.
有没有办法计算除PrimaryKey列之外的特定记录的空值的所有字段?
Example:
ID Name Age City Zip
1 Alex 32 Miami NULL
2 NULL 24 NULL NULL
Run Code Online (Sandbox Code Playgroud)
作为输出,我需要得到1和3.没有明确指定列名.