Closed Thread Icon

Topic awaiting preservation: MySQL HELP (Page 1 of 1) Pages that link to <a href="http://ozoneasylum.com/backlink?for=12804" title="Pages that link to Topic awaiting preservation: MySQL HELP (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: MySQL HELP <span class="small">(Page 1 of 1)</span>\

 
tgullett
Obsessive-Compulsive (I) Inmate

From: Lexington, Kentucky, USA
Insane since: Jun 2003

posted posted 07-02-2003 16:18

Does anyone know of a quick script to run through a database and remove a character?
Or an alternative way...

For some reasons this data that I am importing had at the front and end of each piece of info.

Thanks,
/TCG

Thomas Chase Gullett
tgullett@elinkdesign.com

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 07-02-2003 19:20

tgullett: Hmmmmmmm nothing simple as far as I can tell. I'd do something like:

Grab all the data

Loop the result through a while

In the while grab the data and use string functions to remove the character and then use UPDATE to put the data back in

Close the while loop

There isn't much point me writing the SQL as I don't know your table and field names so you'd essentially have to rewrite the thing anyway.

___________________
Emps

FAQs: Emperor

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 07-02-2003 20:21

well, 'select SUBSTRING(myField,1,length(myField) - 2) from mytable'
should get you what you want.
you could then use a select into, or even an update to get the data change
(like 'update mytable set myField = SUBSTRING(myField,1,length(myField) - 2)').

The manual's your friend

(no gurantees though. Might be that they're numbering from 1, instead of 0, and then the 1 won't cut of the first char, but you'll lose two characters at the end. try that select statement first, before running the update)

« BackwardsOnwards »

Show Forum Drop Down Menu