SQL help

So we've decided to replace three of our existing attribute values with the contact restrictions on the general tab, which we currently aren't using.  Before I get rid of those values I'd like to run an update statement to insert the restriction for those accounts that currently have the attribute.  A SQL whiz I am not.  So I'm able to update the value for one account, but how do I do it for a list of accounts?!  I tried using commas to separate the account numbers, which didn't work.  I'm trying this in test first of course.

Help!

Parents
  • Levi's right about the subquery. But I sense another question in there -- So if you have working code that is doing this for one account number and you want it to do it for three accounts, your working code probably ends with something like...

    where customer_no = 123

    and you tried

    where customer_no = 123, 543, 986

    but what you needed was 

    where customer_no in ( 123, 543, 986 )

    So I hope that helps too. But for something like this where you probably have lots and lots of customers to update rather than three, use Levi's solution. But also close the parenthesis after <some other value>, which he left out accidentally. :)

  •  

    Thanks!  Levi's code worked. I thought we tried paranthesis around the list of account numbers in addition to single quotes and a few other things, but perhaps we didn't .  Anyway, problem solved.  Thanks!

     

Reply Children