PostgreSQL conditional where clause

Check if its null OR your condition like this:

WHERE {client_id} IS NULL OR sr.client_id = {client_id}

The WHERE clause evaluate as follow: If the variable is empty, then the WHERE clause evaluate to true, and therefore – no filter. If not, it continue to the next condition of the OR

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)