How can I update Crate IDs of List of Fruits in si

2019-02-25 16:12发布

In reference to my question,

how can i update SQL table logic

I want a query which will do something like this,

enter image description here

I my last question was confusing hence I am asking a different question.

How can I update Crate IDs of List of Fruits in single SQL query in c#

FruitID and CrateID are foriegn keys and will always in other tables.

1条回答
Summer. ? 凉城
2楼-- · 2019-02-25 16:33

Try using IN:

UPDATE FRUITS
SET CRATE = 'CRATE 7'
WHERE FRUITID IN (1, 2, 3)

Or

UPDATE FRUITS
SET CRATE = 'CRATE 7'
WHERE FRUITName IN ('Mango1', 'Mango2', 'Apple 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)

查看更多
登录 后发表回答