Rob_Quads
Member
Registered: 29th Mar 01
Location: southampton
User status: Offline
|
Got some data I need to manipulate in a database. Currently i have the following lines
update `xxxxxx` set `Build` = 'S000-L120523.4_P-WXSOff' WHERE `Build` LIKE 'S000-L120523.4_P' AND `Custom` LIKE 'GlobalCacheDisabled';
update `xxxxxx` set `Build` = 'S000-L120518.2_P-WXSOff' WHERE `Build` LIKE 'S000-L120518.2_P' AND `Custom` LIKE 'GlobalCacheDisabled';
update `xxxxxx` set `Build` = 'S000-L120528_P-WXSOff' WHERE `Build` LIKE 'S000-L120528_P' AND `Custom` LIKE 'GlobalCacheDisabled';
update `perf_v8_fp01_results` set `Custom` = NULL WHERE `Build` LIKE 'WXSOff' AND `Custom` LIKE 'GlobalCacheDisabled';
Each time a new build comes out I need to add another line. Is there a way of doing something like
Any result with `Custom` LIKE 'GlobalCacheDisabled', set Build = (Currently Build Value) . "-WXSOff'
I'm sure using nested queries its possible but my brains not clicking in this morning.
|
Ian
Site Administrator
Registered: 28th Aug 99
Location: Liverpool
User status: Offline
|
How else are you going to identify the row? You can't select from the table unless you know the build string.
Is there any scope to alter the table design?
|
Rob_Quads
Member
Registered: 29th Mar 01
Location: southampton
User status: Offline
|
No table design is well and truly fixed
Its not the select that the problem. its the update part to replace a field with something thats already there.
|
Ian
Site Administrator
Registered: 28th Aug 99
Location: Liverpool
User status: Offline
|
Select is going to find the new string for you though
Basically design a select using substring with what you want to update with, then nest that inside the update.
My point is you can't make a generic statment without knowing which rows you're going to affect.
|