GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   >>MySQL QUEEERY help yo (https://gfy.com/showthread.php?t=326853)

Juicy D. Links 07-16-2004 10:22 AM

>>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

grumpy 07-16-2004 10:24 AM

update table set fieldname="something" where fieldname="something"

Juicy D. Links 07-16-2004 10:24 AM

:anon :anon

creegan 07-16-2004 10:25 AM

why not do it after the query, like as you're looping stuff out

$string=str_replace("domainA.com", "domainB.com", "$query_result");

pornstar2pac 07-16-2004 10:25 AM

If you go 7-11 today, bring me back some slim jims.


and some pop rocks:winkwink:

Viper2K1 07-16-2004 10:25 AM

update jg_galleries SET fieldyouuseforthedomain="
domainB.com" where fieldyouuseforthedomain="domainA.com";

creegan 07-16-2004 10:26 AM

or you could do update, i figured that domaina.com was in the db for a reason though

Juicy D. Links 07-16-2004 10:27 AM

cool cool

Let me back up the db then try thanks for the help

grumpy 07-16-2004 10:28 AM

Quote:

Originally posted by Viper2K1
update jg_galleries SET fieldyouuseforthedomain="
domainB.com" where fieldyouuseforthedomain="domainA.com";


Thats what i said :-)

Viper2K1 07-16-2004 10:38 AM

Quote:

Originally posted by grumpy
Thats what i said :-)
saw that after i made my post, i type kinda sloooow hehe

Due 07-16-2004 10:54 AM

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();
}

Due 07-16-2004 10:56 AM

replace { with the opening of character for }

woj 07-16-2004 11:58 AM

Quote:

Originally posted by Due
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();
}

there is NO reason at all to do this, when a simple
"UPDATE x SET y WHERE z" query will do just as well...

JSA Matt 07-16-2004 12:01 PM

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

?

Due 07-16-2004 01:52 PM

Quote:

Originally posted by woj
there is NO reason at all to do this, when a simple
"UPDATE x SET y WHERE z" query will do just as well...

Actually there is.
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.

Juicy D. Links 07-16-2004 01:59 PM

Quote:

Originally posted by JSA Matt
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

?

like this

http://www.domainA.com/gallery1/index.html

creegan 07-16-2004 02:02 PM

Quote:

Originally posted by woj
there is NO reason at all to do this, when a simple
"UPDATE x SET y WHERE z" query will do just as well...

unless you plan on expanding your affiliate program with more sites and more hosted galleries, and need to generate the data on the fly

M_M 07-16-2004 02:03 PM

Quote:

Originally posted by Due
Actually there is.
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.


UPDATE tablename SET fieldname = REPLACE(fieldname,'domainA','domainB')


u gotta study more my man

Due 07-16-2004 02:44 PM

Quote:

Originally posted by M_M
UPDATE tablename SET fieldname = REPLACE(fieldname,'domainA','domainB')


u gotta study more my man

Well I just posted a search and replace script I made a few months ago.
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.

SlickCash Sarah 07-16-2004 02:45 PM

This thread reminds me of this..


asdlfkjasd;lfhspdfhglgpoighgpowigwekjhwoeigjkwe

Like Chinese to me.

M_M 07-16-2004 02:46 PM

Quote:

Originally posted by Due
Well I just posted a search and replace script I made a few months ago.
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.

excuses, excuses


j/k :winkwink:

fusionx 07-16-2004 02:48 PM

Quote:

Originally posted by M_M
UPDATE tablename SET fieldname = REPLACE(fieldname,'domainA','domainB')

Assuming the DB is mySql, which it probably is :)

Tom_PMs 07-16-2004 02:50 PM

Oh then Sarah, you'll appreciate this actual copy and paste from Perl documents.

Quote:

If you fork without ever waiting on your children, you will accumulate zombies.

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