sql语句中 “where 1=1” 的用处

通过拼凑sql语句,加入若干个where限制条件,如:select * from table "where conditionA" + ”and conditionB“ + ”and conditionC“ + "and ..."

为了防止table之后出现的单词是”and“,引起语法错误,所以在可以再在 table 后加入”where 1=1“。

posted @ 2017-09-20 10:14  songtianyu  阅读(477)  评论(0编辑  收藏  举报