phpjay Posted July 11, 2011 Share Posted July 11, 2011 i have two tables 1 is remarks one is tbltracking i have remarks_id as primary key in remarks table and ID as primary key also in tbltracking i need to insert a data in remarks table using selecting the table ID from tbltracking table.. structure of my two tables: remarks: remarks_id: primary key remarks: varchar(255) date: time stamp tbltracking: ID: primary key name:varchar(255) DateReceived:date Quote Link to comment Share on other sites More sharing options...
Kustom_Vegas Posted July 11, 2011 Share Posted July 11, 2011 look into using an INSERT SELECT statement http://dev.mysql.com/doc/refman/5.5/en/insert-select.html Quote Link to comment Share on other sites More sharing options...
phpjay Posted July 12, 2011 Author Share Posted July 12, 2011 i have a code here i want to update and insert a data.. how i can add insert here in my code where table2.ID= to remarks.ID include ('connection.php'); $con = mysql_connect("$host","$username","$password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("$db", $con); $acft = $_POST['acft']; $DateIssued = $_POST['DateIssued']; $IssuedTo = $_POST['IssuedTo']; $ID = $_POST['ID']; $remarks = $_POST['remarks']; $sql="UPDATE $table2 SET acft='$acft', DateIssued='$DateIssued', IssuedTo='$IssuedTo' where ID='$ID'"; Quote Link to comment Share on other sites More sharing options...
phpjay Posted July 12, 2011 Author Share Posted July 12, 2011 i have a code here i want to update and insert a data.. how i can add insert here in my code where table2.ID= to remarks.ID include ('connection.php'); $con = mysql_connect("$host","$username","$password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("$db", $con); $acft = $_POST['acft']; $DateIssued = $_POST['DateIssued']; $IssuedTo = $_POST['IssuedTo']; $ID = $_POST['ID']; $remarks = $_POST['remarks']; $sql="UPDATE $table2 SET acft='$acft', DateIssued='$DateIssued', IssuedTo='$IssuedTo' where ID='$ID'"; Quote Link to comment Share on other sites More sharing options...
fenway Posted July 14, 2011 Share Posted July 14, 2011 You mean keep track of the previously inserted UID? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.