Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 mySQL Statement to update field

Author  Topic 

rjbathgate
Starting Member

2 Posts

Posted - 2010-07-22 : 21:41:41
Hey,

I'm not sure I've got this in the right place at all, so apolgoies if it's wrong... esp as it's mySQL on myphpadmin... :)

Background: Standard mySQL database, on php with myphpAdmin running.

I have a field "urlPath", which contains a value, say "/example/imagexx.jpg"

I then have another field "urlPath2" which is blank at moment.

This second field needs to have the value based on the first, for example "/example/two/imagexx.jpg"

So, is there a way to write a SQL statement to say:
1) Get value of urlPath
2) Insert /two/ into a specific place of that value
3) Update this new value into urlPath2

Now I have previously run this through a PHP script to update urlPath2 based on it's value in urlPath --- but

a) I have 110,000 records of this, and PHP script doesn't like that and runs out of memoery, so I have to split the php script into segments, so takes a fair time to actually run through all records

b) I want to learn how I should do it through SQL!


Few notes:
# imagexx is actually the value of field 'num' - So i could pull it from there, but figured as urlPath is fully poulated with /example/imagexx.jpg that would be the best to base urlPath2 on

# I have this three times (urlPath2,urlPath3 and urlPath4), but any one script I can obviously rerun for 3 and 4.

Thanks in advance!

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-07-22 : 21:52:29
ya. you are in the wrong forum
SQLTeam.com is on Microsoft SQL Server. Try posting over at http://www.dbforums.com/mysql/



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -