Well, I thought I could figure it out but I guess I couldn't. This is exactly what I want to do... //Using Access now, but when I use MySQL, I can just get the last insert id.
$itemID = $_POST['item_id']; $itemQty = $_POST['item_qty']; $itemPrice = $_POST['price']; $orderID = Will be a value taken from an auto_increment field in another table. //I'm using PHP and from I have read and have been told, there is no odbc function to get the last insert id, so I'm stuck doing this. INSERT INTO order_history (item_id, item_qty, item_price, order_id) VALUES ($itemID, $itemQty, $itemPrice, $orderID) {Is this where I would do a select and if so how?} So, as you see, I have a combination of values, 3 vars from a form submission, and one value already stored in the database. I know that I could run 2 queries, but that is what I am trying to avoid. Thanks in advance. ---> Jonathan -----Original Message----- From: KH Chiu [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 19, 2003 8:52 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: Is this query possible... Yes. You can use INSERT INTO <table> select from ...... Regards, > All, > > Is this query possible to do: > > I am going to select an id from a table > > SELECT order_id FROM orders WHERE order_start = 1324 > > I will then use the order_id from this query and insert it as well as > some others values I have into another table. > > So in summary, I want to perform a SELECT and INSERT in the same > database query. > > Can I do it? > > If this matters, I will be doing this in 2 different applications. 1 > database is MySQL, and the other is MS Access. > > -jonathan > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <mysql-unsubscribe- [EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php -- Yours, KH Chiu C&A Computer Consultants Ltd. Tel: 3104 2070 Fax: 3010 0896 Email: [EMAIL PROTECTED] Website: www.caconsultant.com --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php