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!
Christina,
This is pseudo code so unfortunately, no cut and paste. But the general idea is to look in tx_cust_keyword for those people with the attribute and the update all those rows in t_customer with a value. So....
update t_customer
set phone_ind = <some value>
where customer_no in (select distinct customer_no from tx_cust_keyword where keyword_no = <attribute id> and key_value = <some other value>
There are certainly other ways of doing this and hopefully you will get a couple of different ideas from others.
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 )
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!
I wish I only forgot them in forum posts :) I've wasted many an hour trying to untangle sub-sub-sub queries when all I needed was one more closing parenthesis.