Query Value from one table and insert into another table.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • underground
    New Member
    • Sep 2006
    • 41

    Query Value from one table and insert into another table.

    I wonder if possible on page load to query the value of a specific colmn and insert the result into another table. My query looks like so

    [PHP]
    <?
    include("includ e/session.php");
    ?>
    <?
    $usr = "xxxx";
    $pwd = "xxxxx";
    $db = "xxxxx";
    $host = "xxxxxx";

    # connect to database
    $cid = mysql_connect($ host,$usr,$pwd) ;
    mysql_select_db ($db);
    if (mysql_error()) { print "Database ERROR: " . mysql_error(); }

    $result = mysql_query("IN SERT INTO audio SELECT pid FROM pix WHERE username='$sess ion->username'");

    ?>
    [/PHP]

    I guess the result I'm trying to acheive is that when the page is opened the above query is executed and the pid is queried base of username and inserted into the audio table. I'm not getting any error messages from the query but pid is not being inserted into the audio table..any ideas!
  • subash
    New Member
    • Sep 2006
    • 32

    #2
    What is your version of MySQL?

    Subash :)

    Comment

    • subash
      New Member
      • Sep 2006
      • 32

      #3
      Hi,


      Better do the following :

      1. Select the value from the table and put into an recordset

      2. Then insert the recordset value into the table

      Subash :)

      Comment

      • underground
        New Member
        • Sep 2006
        • 41

        #4
        Originally posted by subash
        Hi,


        Better do the following :

        1. Select the value from the table and put into an recordset

        2. Then insert the recordset value into the table

        Subash :)
        What is a recordset?

        Comment

        • underground
          New Member
          • Sep 2006
          • 41

          #5
          Okay I did a little research on the term and I'm kinda familiar with it now. When I get home I will create the recrord set query.. I will follow up latter..

          Thanks you for the sugestion...

          Comment

          • underground
            New Member
            • Sep 2006
            • 41

            #6
            I've been hacking away at this for hours with no luck. Record set seem to be a little complicated for the task at hand.

            Comment

            • underground
              New Member
              • Sep 2006
              • 41

              #7
              Sorry for leaving this one open so long. This is another one solved. Thanks for the advice. But I found a better solution...

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                Originally posted by underground
                Sorry for leaving this one open so long. This is another one solved. Thanks for the advice. But I found a better solution...
                If it's possible, could you share the solution so it may help others in a similar situation. Thanks.

                Comment

                Working...