如题:
现在,我自己要写一个sql语句,好麻烦。
code:
public List selCommBeforeUpd() throws Exception {
StringBuffer sbSql = new StringBuffer();
sbSql.append("select c.*,");
sbSql.append(" from tb_commodity c ");
sbSql.append(" where exists (select * from mv_search q ");
sbSql.append(" where q.goodsId = c.qizhouId");
sbSql.append(" and q.lastUpdate != c.lastUpdate) ");
Sql sql = Sqls.create(sbSql.toString());
sql.setCallback(new SqlCallback() {
@Override
public Object invoke(Connection conn, ResultSet rs, Sql sql)
throws SQLException {
List<Commodity> list = new ArrayList<Commodity>();
while (rs.next()) {
Commodity commodity = new Commodity();
commodity.setId(rs.getString("id"));
commodity.setDestId(rs.getString("destId"));
list.add(commodity);
}
return list;
}
});
return sql.getList(Commodity.class);
}