corsasport.co.uk
 

Corsa Sport » Message Board » Off Day » Geek Day » SQL Gurus


New Topic

New Poll
  Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author SQL Gurus
Rob_Quads
Member

Registered: 29th Mar 01
Location: southampton
User status: Offline
30th May 12 at 09:19   View User's Profile U2U Member Reply With Quote

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

Avatar

Registered: 28th Aug 99
Location: Liverpool
User status: Offline
30th May 12 at 13:59   View Garage View User's Profile U2U Member Reply With Quote

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
30th May 12 at 14:24   View User's Profile U2U Member Reply With Quote

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

Avatar

Registered: 28th Aug 99
Location: Liverpool
User status: Offline
30th May 12 at 15:26   View Garage View User's Profile U2U Member Reply With Quote

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.

 
New Topic

New Poll

  Related Threads Author Forum Replies Views Last Post
FAO: Programmers barteh Geek Day 6 777
6th Nov 07 at 14:02
by barteh
 
System Center Configuration Manager 2007 Pablo Geek Day 13 353
6th Feb 08 at 14:39
by Pablo
 
Php help? (mysql_num_rows) Whittie Geek Day 17 1506
15th Jan 10 at 14:38
by Dom
 
Database Gurus Bart Geek Day 8 546
15th Mar 11 at 18:35
by Bart
 
SQL Experts Bart Geek Day 1 263
7th Jul 11 at 18:09
by Mike2k111
 

Corsa Sport » Message Board » Off Day » Geek Day » SQL Gurus 29 database queries in 0.0082991 seconds