Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Databasing
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 10-08-2009, 10:28 AM
  #1
cmetz1977
Myrmidon (Level 12)
 
cmetz1977's Avatar
 
Join Date: May 2008
Location: Lakeland, FL
Posts: 193
iTrader: (0)
cmetz1977 will become famous soon enough
Mulltiple UPDATEs in a single statement

Is there a way to run multiple UPDATE operations within a single statement, using independant criteria? Hypothetical syntax:

PHP Code:
UPDATE street_abbreviations
   
(SET abbreviation 'Blvd' WHERE street 'Boulevard')
AND
   (
SET abbreviation 'Ln' WHERE street 'Lane'
__________________
Never accept Kool-aid from someone who won't drink from the same punch bowl.
cmetz1977 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-08-2009, 11:38 PM
  #2
Horus_Kol
Mod of the Underlay
 
Horus_Kol's Avatar
 
Join Date: Jun 2002
Location: At a desk, hooked up and ready to rock
Posts: 17,242
iTrader: (0)
Horus_Kol is a glorious beacon of lightHorus_Kol is a glorious beacon of lightHorus_Kol is a glorious beacon of lightHorus_Kol is a glorious beacon of lightHorus_Kol is a glorious beacon of light
The best I can come up with after a short bit of testing is:
Code:
UPDATE street_abbreviations SET abbreviation = street;

UPDATE street_abbreviations SET abbreviation = REPLACE(abbreviation, 'Boulevard', 'Blvd'), abbreviation = REPLACE(abbreviation, 'Lane', 'Ln');
I did try simply:
Code:
UPDATE street_abbreviations SET abbreviation = REPLACE(street, 'Boulevard', 'Blvd'), abbreviation = REPLACE(street, 'Lane', 'Ln');
but that would only work for the last match...
__________________
Personal Blog (and photos): HorusKol
Articles on Programming and Development (PHP/HTML/CSS, C/C++, more): RandomTweak

The great secret that no SEO agent wants you to hear: if you build your website using w3c accessibility guidelines and your content is written for people, you will do better for longer in search engines than any other method...
Horus_Kol is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-09-2009, 09:08 AM
  #3
cmetz1977
Myrmidon (Level 12)
 
cmetz1977's Avatar
 
Join Date: May 2008
Location: Lakeland, FL
Posts: 193
iTrader: (0)
cmetz1977 will become famous soon enough
I had assumed you could only do one update at a time, but figured it would be faster to do multiple updates in one statement as compared to one update per statement in multiple statements.

Thank you.
__________________
Never accept Kool-aid from someone who won't drink from the same punch bowl.
cmetz1977 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote

Reply
KEEP TABS
SPONSORS
 
Boxedart
 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 03:34 AM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.