![]() |
>>MySQL QUEEERY help yo
Check it out
I got galleries in a table jg_galleries in that table the main domain url is domainA.com Can i so some fancy sql shit to replace doaminA.com with domainB.com in one queeeeery? :helpme |
update table set fieldname="something" where fieldname="something"
|
:anon :anon
|
why not do it after the query, like as you're looping stuff out
$string=str_replace("domainA.com", "domainB.com", "$query_result"); |
If you go 7-11 today, bring me back some slim jims.
and some pop rocks:winkwink: |
update jg_galleries SET fieldyouuseforthedomain="
domainB.com" where fieldyouuseforthedomain="domainA.com"; |
or you could do update, i figured that domaina.com was in the db for a reason though
|
cool cool
Let me back up the db then try thanks for the help |
Quote:
Thats what i said :-) |
Quote:
|
This might be what you are looking for:
$searching="FIND-THIS"; $replace="REPLACE-WITH-THIS"; $res = mysql_query("SELECT * FROM jg_galleries WHERE url LIKE '%$searching%'"); while($row = mysql_fetch_array($res)) { $surl++; $my_id[$surl] = $row[id]; $my_thumb[$surl] = $row[url]; } while($y<$surl){ $y++; $newurl[$y]=str_replace("$searching", "$replace", $my_thumb[$y]); $query = mysql_query("UPDATE jg_galleries SET url='$newurl[$y]' WHERE id='$my_id[$y]'") or print mysql_error(); } |
replace { with the opening of character for }
|
Quote:
"UPDATE x SET y WHERE z" query will do just as well... |
Did you solve this yet? What do the entries look like?
Are they like: http://www.domainA.com/ or more like http://www.domainA.com/gallery1/index.html ? |
Quote:
Else "y/gallery/whatever/213423.html" will just be replaced with "x" when it should have been "x/gallery/whatever/213423.html" I asume he have 100's or 1000's of galleries saved on 1 domain that need to be updated to be on another domain. |
Quote:
http://www.domainA.com/gallery1/index.html |
Quote:
|
Quote:
UPDATE tablename SET fieldname = REPLACE(fieldname,'domainA','domainB') u gotta study more my man |
Quote:
Got nothing to do with if I need to study more or not. :winkwink: The original search and replace script contained a lot more functions that included updating other tables for some of the results depending on what was returned from the first result. So a simple replace wouldn't be good enough for what I needed it for. |
This thread reminds me of this..
asdlfkjasd;lfhspdfhglgpoighgpowigwekjhwoeigjkwe Like Chinese to me. |
Quote:
j/k :winkwink: |
Quote:
|
Oh then Sarah, you'll appreciate this actual copy and paste from Perl documents.
Quote:
My favorite! :1orglaugh |
All times are GMT -7. The time now is 09:52 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123