简体   繁体   English

如何将最后一条记录的+1添加到mysql c# winform

[英]how to add + 1 of the last record to mysql c# winform

In general, I have a test.一般来说,我有一个测试。 During the passage of which the user receives points.在用户获得积分的过程中。 And when another user passes the same test, points are assigned to both the first user and the second当另一个用户通过相同的测试时,分数将分配给第一个用户和第二个用户

how to assign points to the last user?如何给最后一个用户分配积分?

my mysql query我的mysql查询

MySqlCommand command =
    new MySqlCommand("update `journal` set `balls` = `balls` + 1", db.getConnection());

solving the problem解决问题

update journal set balls = balls + 1 where id = LAST_INSERT_ID()

You should get the last data first before you execute update query在执行更新查询之前,您应该先获取最后的数据

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM