I want to insert a record into the Booking_Sheet table when the user enters their information on an HTML document. First, some of the information is stored in the Client_Database table, and then I want the rest of the information to be stored in the Booking_Sheet but I want the record on the Booking_Sheet to contain information that was just inserted, such as the AutoNumber Client_ID from Client_Database, which I am doing with a select max statement. Although this is not working. I was wondering if it is possible to have a SELECT statement imbedded within VALUES?
$sql="INSERT INTO Booking_Sheet (Client_ID, Client_Name)
VALUES ((SELECT MAX(ID) FROM Client_Database), '$name');";
if(odbc_exec($con,$sql))
{
echo "<br>Data saved<br>Please Wait Page redirect..";
header("refresh:1;url=index.php");
}
else
{
echo "Error";
}
Apparently not. I just tried within Access and it fails. However, don't need VALUES.
"INSERT INTO Booking_Sheet (Client_ID, Client_Name) SELECT MAX(ID), '$name' FROM Client_Database";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.