If you automatically want to add restrictions to your query, it makes your life easier:
string sql = "SELECT * FROM table WHERE 1=1";
if (someflag) {
sql += " AND valid = 1";
}
if (someotherflag) {
sql += " AND special = 1";
}
execute(sql);
Without WHERE 1 = 1
you would in each case have to check if it's the first restriction you add (and then use WHERE ...
) or if you already added some other restriction before (and then add AND ...
).