SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    446
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    moving data from one file to another

    Is there a function or simple technique for moving data from one MYSQL file to another when the column names from the source file match the column names of the target file other than using mysql_fetch_array?

    If so, what do you recommend?

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,014
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    what do you consider a mysql "file" ??
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    446
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    A file that I can access with phpmyadmin

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,014
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    you mean a database? or a table within a database?
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    446
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    table.

    I found SELECT INTO.

    I'm tried using:

    mysql_query("SELECT cliorder INTO plan2 FROM preplan") or die(mysql_error());

    but got an error that said: Undeclared variable: plan2

    plan2 already exists as a table. Am I on the right track?

  6. #6
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    446
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    mysql_query("INSERT INTO plan2(cliorder) SELECT cliorder FROM preplan") or die(mysql_error());

    Thanks r937. It's always good to know you'll help.

  7. #7
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,014
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    you shouldn't need to run that query in a php program -- just run it in your front end app (phpmyadmin or whatever)

    if you plan on copying data from one table (not file) to another more than once, you should probably re-think why
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  8. #8
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    446
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    excellent points! I keep forgetting about running it through myphpadmin although php provides a way to track the work.

    Thanks again r937.

    Niche


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •