sql语句 字段之间的加减乘除

版权声明:博客知识产权来源命运的信徒,切勿侵权 https://blog.csdn.net/qq_37591637/article/details/89435774

举一个小栗子

count 是Int类型的 (代表用户评价的条数)

start是Int类型的(代表星级,星级是根据用户打的星求平均值)

我现在要在是count在原有的基础上加一

start则是count*start+变量/count+1



sql语句如下

int start = o.getStart();
		start = start / 3;
		// 律师综合星级要改变
		String sqls = "update Comprecondition set count=count+1,start=(start*count+'"+start+"')/count where lanme=?";
		Query querys = session.createSQLQuery(sqls);
		querys.setString(0, lanme);
		System.out.println("律师名:" + lanme);
		querys.executeUpdate();

猜你喜欢

转载自blog.csdn.net/qq_37591637/article/details/89435774