数据库更新问题

发布于 2024-10-08 02:00:09 字数 359 浏览 0 评论 0原文

我正在使用 MySql 并且对它还很陌生。

我有一个表,每 X 秒存储 5 个测量值(可配置,但每次测试运行前始终相同)

我通过串行端口进行 4 个测量,但另一个必须手动测量。

每次在 4 个串行端口(每 X 秒)进行测量时,我都会写入带有时间戳的新行,这意味着手动测量的值将写入上次测量时的值。

现在,假设用户在 10:000:00 采样并进行手动分析,并在 2 分钟后返回,将值输入到我的程序中...我已经编写了 10:00 期间的前一个值: :到 10:02:00,我必须返回并将它们更新为刚刚输入的值。

有没有一个简单的语句可以做到这一点?只需锁定表或数据集,找到两个时间戳之间的所有行并将一列更新为新值,然后解锁?

I'm using MySql and am pretty new to it.

I have a table which stores 5 measurements every X seconds (configurable, but always the same fore each test run)

I am taking 4 measurements over serial port, but the other must be measured manually.

I write a new row, with timestamp, every time I measure at the 4 serial ports (every X seconds), which means that value of the manual measurement is written as its value last time it was measured.

Now, suppose the user takes a sample at presciently 10:000:00 and goes to manually analayze and comes back 2 minutes later to enter the value into my program... I have already written the previous value for the period 10:00:: to 10:02:00 and I have to go back and update them to the value just entered.

Is there one simple statement that will do that? just lock the table or dataset, find all rows between two timestamps and update one column to the new value, then unlock?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情仇皆在手 2024-10-15 02:00:09
      UPDATE Measurements
         SET ManualMeasurement = 'someNumber'
       WHERE TimeTaken Between 'startTime' AND 'endTime'

这就是你正在寻找的东西吗?

      UPDATE Measurements
         SET ManualMeasurement = 'someNumber'
       WHERE TimeTaken Between 'startTime' AND 'endTime'

is that the sort of thing you are looking for?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文