sql - Updating a column value for multiple rows based on a condition -


i trying update column multiple rows. following query

update [members]  set [credits]=[credits]+@freecredits  [id] in (select t1.[memberid]                 @members t1                 right join [members] t2 on t1.memberid!=t2.id                 t2.activeplan null) 

what trying that, want add free credits members' accounts don't have active plan (=null). list of members in @members table-valued parameter , [members] table.

the query not working expected. it's adding credits members, has [activeplan] not equal null. please tell me how achieve using 1 update query.

sorry, bother guys. after posting question solution clicked in mind. tried following simple query , worked :)

update [members] set [credits]=[credits]+@freecredits [id] in (select [memberid] @members) , [activeplan] null 

please see if has problems. thank :)


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -