这段代码里的 and是什么意思?希望大神能逐句给解释下,万分感谢

这段代码里的 and是什么意思?希望大神能逐句给解释下,万分感谢

``

public List getList(int userId, Pager pager) {
String where = " ";
if (0 < userId) {
where = where + " and t.userId = " + userId;
}
return this.findAll(where, pager);
}


 and就是数据库中的与,和java语言没关系,建议去看一下SQL语句的基础。

表sql语句里面的and 比如:“select * from students where name='xxx' and age>10"查询Students表中名称为xxx且年龄大于10的数据,而这里就是为了拼接一串这样的字符串。
如果xxx是个变量,我们就这样写
string strName="xxx";
string sql="select * from students where name='"+strName+"' and age>10";

很明显这是一个拼接语句,前后是有“ ” 号的 你再仔细的理清一下逻辑

and就是数据库中的与,和java语言没关系,建议去看一下SQL语句的基础。

拼接多个sql条件,实现动态构造查询