Update Query Single Column Multiple Rows But Not All

Go To StackoverFlow.com

0

I'm using the SQL query box in phpMyAdmin (MyISAM). Below works fine unless I try updating more than one row at a time. Can someone tell me what I'm doing wrong?

UPDATE table_name SET column_name = 'Air' WHERE row_name = 's003';

If I try adding say 'tr003, s005'; -- that won't work. I get message "0 rows affected". I have searched but couldn't find help for this. Thank you.

2012-04-04 18:00
by acvintage


0

You can use an IN clause for this:

UPDATE table_name 
SET column_name = 'Air' 
WHERE row_name in ('s003', 'tr003', 's005');
2012-04-04 18:00
by RedFilter
Thank you, RedFilter - thought I had tried that but didn't work at the time. I copied yours exactly and it worked (must have left something out before. I also just trie - acvintage 2012-04-04 18:21
Well, forget what I was trying to add to my comment...I have the most wicked time trying to post my comments in acceptable format - it's quite intimidating. Thank goodness I find answers to most of my questions by trolling. I really appreciate this forum - acvintage 2012-04-04 18:38
Ads