|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
I need some help running a conditional update on a database. I need to update all rows where xField has 3 characters and append 'xx' to the beginning of it.
Such as 'Cat' would be 'xxCat'. there are about 42,000 rows and it would be a nightmare to have to update them all by hand. I know that i can select them all with Code:
SELECT * FROM `database` WHERE CHAR_LENGTH(field) = 3 i also know that you can run an update like: Code:
UPDATE `database` SET field = 'xxCat' WHERE field = 'Cat' but each row is something different. Any help would be greatly appreciated |
|
#2
|
||||
|
||||
|
Would something like this work?
Code:
UPDATE `database` SET field = CONCAT('xx', field) WHERE CHAR_LENGTH(field) = 3
I'm really not sure whether that will work, I suggest you try that out in a database that is not in production use.
__________________
Fight Internet censorship! Code:
() ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > MySQL 4.1 - Conditional Update |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|