List:General Discussion« Previous MessageNext Message »
From:Gleb Paharenko Date:September 8 2005 6:15pm
Subject:Re: Copying data stored in different field formats from one table to another
View as plain text  
Hello.

This is not a step by step instructions. But taking into an account
that you're a MySQL beginner, in my opinion, you should read some
parts of the manual:
  http://dev.mysql.com/doc/mysql/en/string-functions.html
	http://dev.mysql.com/doc/mysql/en/insert-select.html
	http://dev.mysql.com/doc/mysql/en/numeric-types.html
	http://dev.mysql.com/doc/mysql/en/show-warnings.html
	http://dev.mysql.com/doc/mysql/en/string-types.html


I recommend you to upgrade your MySQL to the latest release (4.1.14
now). See:
  http://dev.mysql.com/doc/mysql/en/upgrade.html





Dave <davemg@stripped> wrote:
> MySQL General List,
> 
>    Server specifications:
>    MySQL 4.1.3-beta, phpMyAdmin 2.5.7-pl1, PHP 4.3.8
>    My specifications:
>    MySQL beginner, PHP intermediate, HTML and CSS advanced.
> 
>    The situation:
>    I have recently installed a forum ( http://www.simplemachines.org/ ) 
> on my web site. I already have about 150 users on my site, and I want to 
> transplant their information from their current table into the members 
> table used by the forum.
>    With many of the necessary fields, this means I have to take the 
> format of the current data and put it into a the new field with a 
> different format.
> 
>    The Questions:
>    In the following 5 cases, will it be safe to copy data directly, or 
> will there be data loss or scrambling:
> 
>    1. In the first case, the id number for the original table is an 
> INT, with a length of 11. In the target table, it's a MEDIUMINT with a 
> length of 8. Since I only have 150 members starting at an id of 1, I'm 
> assuming I can just copy the numbers without fear of truncation
> 
>    2. The username in the source table is a VARCHAR with a length of 
> 80, but the destination has a length of 16. What will happen to the data 
> in the destination table if it's longer than 16? Will it be truncated or 
> rejected?
> 
>    3. The third case I'm a little confused about. In the source table, 
> I have a field for recording the date that the member joined. This is 
> stored in DATE format. The destination table uses a simple INT with a 
> length of 10. I this is a Unix time stamp format, because according to 
> the forum web site, you can access it from PHP using the time() 
> function. So would the command be something like:
>    COPY DATE(members.joindate) TO 
> UNIX_TIMESTAMP(forum_members.dateRegistered)
>    ...?
> 
>    4. For storing email addresses, the source table uses a VARCHAR 
> field with a length of 100. In the destination it's a TINYTEXT. If I 
> understand correctly, TINYTEXT should hold 256 characters, so there 
> should be enough room.
> 
>    5. The last case I need to combine two fields into one. The source 
> table uses seperate fields for first name and last name, and each is a 
> VARCHAR with a length of 100. In the destination table, first and last 
> names are stored in the same field, with a TINYTEXT format.
>    However, despite the fact that I've looked up "combine fields" and 
> "concatenate fields" on Google, I can't find instructions on how to do 
> that in reference to merging two fields into one, or copying from one 
> field to another. All the references I found are for querying the 
> database, combining data at the point of user input. How do I combine 
> two fields from one table, and put them into another?
> 
>    Any assistance is much appreciated. Thank you.
> 
> Dave
> 


-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.NET http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Gleb Paharenko
 / /|_/ / // /\ \/ /_/ / /__   Gleb.Paharenko@stripped
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.NET
       <___/   www.mysql.com



Thread
Copying data stored in different field formats from one table toanotherDave8 Sep
  • Re: Copying data stored in different field formats from one table to anotherGleb Paharenko8 Sep
    • Re: Copying data stored in different field formats from one tableto anotherDave12 Sep
      • Re: Copying data stored in different field formats from one tableto anotherJohan Höök12 Sep
        • Re: Copying data stored in different field formats from one tableto anotherDave12 Sep
          • Re: Copying data stored in different field formats from one tableto anotherJohan Höök12 Sep
            • Re: Copying data stored in different field formats from one tableto anotherDave12 Sep
              • Re: Copying data stored in different field formats from one tableto anotherJohan Höök12 Sep
                • Re: Copying data stored in different field formats from one tableto anotherDave12 Sep
                  • Re: Copying data stored in different field formats from one tableto another [PARTIALLY SOLVED]Dave13 Sep
  • Re: Copying data stored in different field formats from one table to anotherGleb Paharenko12 Sep