更新声明

发布于 2024-07-13 04:33:21 字数 251 浏览 6 评论 0原文

我是一名 SQL 初学者(未经过正式培训;仅在职培训),需要一些简单更新语句的帮助。 我想写一个更新语句来允许我列出 ID。 下面显示的声明是我目前正在编写的。 理想情况下,该声明允许我将其写成“where plantunitid in (49-57)”。有办法做到这一点吗?感谢提供的任何帮助。

更新 plantfunctiontable 设置退役=1 其中 plantunitid 位于 (49,50,51,52,53,54,55,56,57)

I am a beginner SQL user (not formally trained; OJT only) and need some assistance with a simple update statement. I would like to write an update statement that allows me to list ID's. The statement shown below is how I am currently writing it. Ideally, the statement would allow me to write it like "where plantunitid in (49-57). Is there a way to do this? Thanks for any assistance provided.

update plantfunctiontable
set decommissioned=1
where plantunitid in (49,50,51,52,53,54,55,56,57)

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

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

发布评论

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

评论(5

暗地喜欢 2024-07-20 04:33:21

这行得通吗?

update plantfunctiontable set decommissioned=1 where plantunitid  between 49 and 57

Can this work?

update plantfunctiontable set decommissioned=1 where plantunitid  between 49 and 57
情痴 2024-07-20 04:33:21

您可以使用

Where plantunitid >= 49 AND plantunitid <= 57

Where plantunitid BETWEEN 49 and 57

You can use

Where plantunitid >= 49 AND plantunitid <= 57

OR

Where plantunitid BETWEEN 49 and 57
謸气贵蔟 2024-07-20 04:33:21

那应该按原样工作。

或者你也可以这样做。

Update planfunctiontable set decommissioned = 1 where plantunitid between 49 and 57

假设您的范围始终是连续的 (1,2,3....7,8,9)

That should work as is.

Or you can do it like this.

Update planfunctiontable set decommissioned = 1 where plantunitid between 49 and 57

assuming that your range will always be sequential (1,2,3....7,8,9)

小ぇ时光︴ 2024-07-20 04:33:21

只有当它是连续的时,你才能使用它。

UPDATE plantfunctiontable
   SET decommissioned = 1
 WHERE plantunitid BETWEEN 49 AND 57

如果不是连续的,您的原始查询可以正常工作

UPDATE plantfunctiontable
   SET decommissioned = 1
 WHERE plantunitid IN (49, 50, 51, 52, 53, 54, 55, 56, 57)

Only if it's sequential, can you use that.

UPDATE plantfunctiontable
   SET decommissioned = 1
 WHERE plantunitid BETWEEN 49 AND 57

If not sequential, your original query works fine

UPDATE plantfunctiontable
   SET decommissioned = 1
 WHERE plantunitid IN (49, 50, 51, 52, 53, 54, 55, 56, 57)
温暖的光 2024-07-20 04:33:21

尝试

Update plantfunctiontable
SET decommissioned = 1
WHERE plantunitid >= @startID
AND plantunitid <= @endID

其中 @startID 和 @endID 是您的语句参数。 希望有帮助

try

Update plantfunctiontable
SET decommissioned = 1
WHERE plantunitid >= @startID
AND plantunitid <= @endID

where @startID and @endID are your statements parameters. hope that helps

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