Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating one field in multiple records with one form 1

Status
Not open for further replies.

balooDog

Technical User
Oct 3, 2002
4
US
I need to figure out how to update one field in multiple records with one form as a way to activate several accounts at once.

When I display the records of new accounts, I list each name with a check box to activate the account.

Is there a way to make it possible to check all the boxes on the page and submit the form so that the activate field in all new records in the accounts table are updated at once?

Any ideas are appreciated,
BalooDog:)
 
Sure... in your UPDATE's WHERE clause, simply specify multiple records.

ie -
Code:
UPDATE tablename SET activate='yes' WHERE userid IN ('0001','0002','0003')

Would set the value of activate to "yes" for users 0001, 0002, and 0003.

Or even
Code:
UPDATE tablename SET activate='yes' WHERE activate = 'no'

would set active to "yes" for all users where it's currently set to "no".

Of course... the more users you set with a single update, the more danger there is that you're not setting the records you intended ;-)
Hope it helps,
-Carl
 
Thanks, It sounds like I'm really over thinking this problem....but what if I also want to be able to activate only a random few of the accounts that appear on the new accounts page?
Thanks,
BalooDog[hourglass]
 
That would be the first solution presented. The WHERE...IN statement.

Basically, you would simply need to adjust your WHERE clause however you deemed appropriate to update just the rows you wanted to update. What "appropriate" means is entirely up to you and your specific needs.
Hope it helps,
-Carl
 
Thanks, Carl...it works perfectly!
I WAS totally over thinking the whole issue. That seems to be the problem whenever I encounter something I haven't done before with coldfusion - I over think it!

Thanks Again[thumbsup2],
Angela
 
Overthinking isn't a bad thing.

It shows that you're, at least, thinking. And it makes it that much more pleasant when you realize the solution isn't half as bad as you thought it'd be ;-)
Hope it helps,
-Carl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top