Suppose we have a table employees which contains name, employee_id and citizen_id. We want to filter the table using also 3 python variables name, employee_id and citizen_id for the WHERE clause. Example:
name = 'John'
citizen_id = 'ID001'
employee_id = 'EMP023'
The condition is those 3 variables are NULLABLE, one or two of them can be NULL but at least one variable are not.
How we create a sql query that allow one/two of that 3 variables in the WHERE clause?
('''SELECT
*
FROM
people
WHERE
name = '{0}'
OR citizen_id = '{1}'
OR employee_id = '{2}'''').format(name, citizen_id, employee_id)