What is the purpose of using WHERE 1=1 in SQL statements? [duplicate]

It’s also a common practice when people are building the sql query programmatically, it’s just easier to start with ‘where 1=1 ‘ and then appending ‘ and customer.id=:custId’ depending if a customer id is provided.
So you can always append the next part of the query starting with ‘and …’.

Leave a Comment

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