Lets say its 2001 and you are writing some hot e-commerce stuff in plain php. You want to filter data depending on multiple fields in the submitted form. If some field is there, you add one more "AND" clause to the "WHERE", like this: if (isset($_POST['product'])) { $query .= "AND product = " . $_POST['product']; }. So in order not to check every time if the added clause is the first one you start with "WHERE 1=1 ", as "WHERE AND ..." would not work.
freilanzer|1 year ago
In [1]: "... WHERE " + " AND ".join(str(i) for i in range(4))
Out[1]: '... WHERE 0 AND 1 AND 2 AND 3'
Very strange.
egormakarov|1 year ago
paperplatter|1 year ago