SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    dump query result to another table

    How do I insert the result (colume1) from this query to another table?

    SELECT colume1 FROM table1 ORDER BY count DESC
    Trigger8

    **************************
    I killed a 6-pack just to watch it die!

  2. #2
    epsilon transition cupid's Avatar
    Join Date
    Aug 2001
    Location
    Kent, Ohio
    Posts
    367
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    With or without the use of PHP? Has the other table already been created with the appropriate field specifications?

  3. #3
    SitePoint Zealot trigger8's Avatar
    Join Date
    Nov 2000
    Location
    Dallas, TX
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Let's assumed that another table is already there named table2, and the column named column2.
    Trigger8

    **************************
    I killed a 6-pack just to watch it die!

  4. #4
    epsilon transition cupid's Avatar
    Join Date
    Aug 2001
    Location
    Kent, Ohio
    Posts
    367
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I suppose this could be a solution. Haven't tested it, but it should work.

    PHP Code:

    $query 
    mysql_query("select column1 from table1");
    while (
    $result mysql_fetch_object($query)) {

      
    mysql_query("insert into table2 (column2) values ('".$result->column1."')");




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
  •