Greenguy's Board

Greenguy's Board (http://www.greenguysboard.com/board/index.php)
-   Programming & Scripting (http://www.greenguysboard.com/board/forumdisplay.php?f=15)
-   -   MySql statement needed (http://www.greenguysboard.com/board/showthread.php?t=33413)

CelticTiger 2006-08-03 07:39 AM

MySql statement needed
 
Can someone tell me if there is a MySql statement that will do a search and replace on a database? Or any alternative maybe?

porno0net 2006-08-03 07:49 AM

Quote:

Originally Posted by CelticTiger
Can someone tell me if there is a MySql statement that will do a search and replace on a database? Or any alternative maybe?


UPDATE links SET niche='Amateur' WHERE niche='Amaateur';

UPDATE links SET niche='Hairy',status='Active' WHERE submitter='xxxx' AND email like 'some_dude%';

I hope this helps :D

CelticTiger 2006-08-03 08:40 AM

Quote:

Originally Posted by porno0net
UPDATE links SET niche='Amateur' WHERE niche='Amaateur';

UPDATE links SET niche='Hairy',status='Active' WHERE submitter='xxxx' AND email like 'some_dude%';

I hope this helps :D

Thanks for your help - I'm a dumbass when it comes to this stuff so can you clarify it a little for me? Basically what I want to do is remove all instances of any exclamation marks(!) within any link descriptions.

cd34 2006-08-03 10:10 AM

create tablenamebackup select * from tablename;
update tablename set fieldname=replace(fieldname,'!','');

tablenamebackup = whatever you want that signifies that you made a backup
tablename = the table that contains the data you want to change
fieldname = the name of the field that has the data you want to change

if you don't know the name of the table or how the table is laid out:

show tables;
describe tablename;

If you're using phpmyadmin, you should be able to navigate through and get the info from the command above.

note, if you screw up:

delete from tablename;
insert into tablename select * from tablenamebackup;

CelticTiger 2006-08-03 11:06 AM

Thanks cd34 - that did the biz |bow| I still had to call in Chop to point out that my spelling was wrong in the statement which led to me wasting his time and mine |shocking|


All times are GMT -4. The time now is 06:26 AM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc