Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update selective rows in a table in sql server?

Tags:

c#

sql

asp.net

I am working in an application in which user selects some rows in a gridview by clicking on check boxes associated with each row and in selected rows only one value should be updated in database. I am using following query

 update Items
 set bitIsTab = 1
 where ReqID = 3

Suppose that user selects 4 values from gridview and i have to set these 4 rows bitIsTab to 1.How to update these rows by calling query one time or i have to call the same query as many times as the number of records selected.


1 Answers

If you know the ReqIDs you can do

update Items
set bitIsTab = 1
where ReqID in (1,2,3,4)
like image 83
juergen d Avatar answered Mar 21 '26 05:03

juergen d



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!