Gossamer Forum
Home : Products : Others : MySQLMan :

Need some queries...

Quote Reply
Need some queries...
Hello all, I am new to mySQL and currently having some difficulties on changing fields data.

I am importing data from flat text database and the ID number field has some duplicates which will screw my data up.
Is there any query to be run to change or make a new ID numbers for my table?

Thank you for any help.

rgds

__________________________
SantanaBlank
Quote Reply
Re: [santana] Need some queries... In reply to
Not as a part of MySQLman, no. However, it would be easy to write a few lines of code, in perl, that will change each field in your text file.

Cheers

- wil
Quote Reply
Re: [santana] Need some queries... In reply to
For example...if your text file is like.....

ID|Bla......

You could do:
Code:
my $i = 0;
open DB1, "<mydatabase.db";
open DB2, ">mynewdata.db";
while (<DB1>) {
$i++;
s,^\d\|,,;
print DB2 "$i|$_";
}
close DB2;
close DB1;


Last edited by:

RedRum: Sep 20, 2001, 6:05 AM
Quote Reply
Re: [RedRum] Need some queries... In reply to
As my assistant is about to show you ;-)
Quote Reply
Re: [Wil] Need some queries... In reply to
Good job I came back to the thread to read your message.....I missed $i++; Blush