问答详情
源自:2-6 JDBC实战---搭建模型层 Ⅳ

where 1=1?

那个select * from imooc_goddess where 1=1那块,不能把把sb.append(" where ")放到for语句上面吗

提问者:eJhinilly 2017-06-07 15:47

个回答

  • 和风细羽
    2017-06-07 16:40:39
    已采纳

    那样的话得到的sql语句就是: where and user_name=...

    1=1 是为了接上 for 循环里的 and,那么 sql 语句就是 where 1=1 and user_name=...