How can I update Crate IDs of List of Fruits in single SQL query in c#(如何在 c# 中的单个 SQL 查询中更新水果列表的箱 ID)
问题描述
关于我的问题,
如何更新 SQL 表逻辑
我想要一个这样的查询,
I want a query which will do something like this,
我的最后一个问题令人困惑,因此我问了一个不同的问题.
I my last question was confusing hence I am asking a different question.
如何在 C# 中的单个 SQL 查询中更新水果列表的 Crate ID
FruitID 和 CrateID 是外键,将始终在其他表中.
FruitID and CrateID are foriegn keys and will always in other tables.
推荐答案
尝试使用IN
:
UPDATE FRUITS
SET CRATE = 'CRATE 7'
WHERE FRUITID IN (1, 2, 3)
或
UPDATE FRUITS
SET CRATE = 'CRATE 7'
WHERE FRUITName IN ('Mango1', 'Mango2', 'Apple 6')
您也可以使用 LIKE
来匹配 Mango
和 Orange
但这可能会更新不正确的结果(假设您希望更新 Orange 199到 Crate 7 但希望 Orange 198 成为 Crate 6)
You can also use LIKE
to match Mango
and Orange
however this may update the incorrect results (Say you want Orange 199 to be updated to Crate 7 but want Orange 198 to be Crate 6)
这篇关于如何在 c# 中的单个 SQL 查询中更新水果列表的箱 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 c# 中的单个 SQL 查询中更新水果列表的箱


- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 如何用自己压缩一个 IEnumerable 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 输入按键事件处理程序 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01