'PostgreSQL apply filter only if column exists
I am building an application which will construct SQL query (in Postgres) and apply some filtering to it. The problem is, once the filter is selected in the app, all the queries are receiving it, and sometimes we use tables which do have columns used in a filter.
Is there a way to skip filter if the column does not exist?
In pseudocode something like:
SELECT * FROM table WHERE [if col exists] col > 1;
I was not able to find anything like that, but maybe there are some tricks.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
