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

后端 未结 1 1928
无人共我
无人共我 2021-01-22 11:07

In reference to my question,

how can i update SQL table logic

I want a query which will do something like this,

相关标签:
1条回答
  • 2021-01-22 12:03

    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)

    0 讨论(0)
提交回复
热议问题