By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,310 Members | 1,466 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,310 IT Pros & Developers. It's quick & easy.

possible to shift and splice colums?

P: n/a
In MYSQL is it possible to shift and splice colums?
say I have a table w/fields: name | tele_num | age
and I get all the addresses later - address initally
stored in a txt type file with 1 rec /line.
I now want: name | address | tel_num | age
Can I do it this? if not can I do:
name | tele_num | age | address ?

Just need the tools cmds to use and the "flow"
you don't have give the actual SQL unless you want.
Thanks,
Lee G.
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
leegold2 wrote:
In MYSQL is it possible to shift and splice colums?
You're asking about adding a column to a table, right?

See this page:
http://dev.mysql.com/doc/mysql/en/ALTER_TABLE.html

and maybe this page:
http://dev.mysql.com/doc/mysql/en/Loading_tables.html

But matching up the addresses to the right records is a perennial
problem with data loads. I don't know of an easy way to do it. There's
no SQL syntax for UPDATE to say, "update the address field with value X,
one record at a time, for records matching the person's name Y."

The best thing I can suggest is to write a script in your favorite
language, loop through your text file of addresses, and execute a
separate UPDATE statement for each line:
UPDATE MyTable SET address = "..." WHERE name = "..."
Fill in the ellipses with the corresponding values on each given line of
the text file.

Sometimes I write a Perl script that reads the text file, find the
relevant strings, and outputs a series of SQL UPDATE statements, one for
each line of the text file. Then the result of that can be input as a
script to the familiar mysql CLI.

Sounds like an opportunity for some shareware software developer to
write a wizard-based GUI tool to do this sort of thing!

Regards,
Bill K.
say I have a table w/fields: name | tele_num | age
and I get all the addresses later - address initally
stored in a txt type file with 1 rec /line.
I now want: name | address | tel_num | age
Can I do it this? if not can I do:
name | tele_num | age | address ?

Just need the tools cmds to use and the "flow"
you don't have give the actual SQL unless you want.
Thanks,
Lee G.


Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.