PDA

View Full Version : Query on Using Queries


DPoole
09-13-2003, 10:33 AM
Hello

Just trying to keep the query count down on the board.

Say for example you have a query to add some data onto the table



$DB_site->query("INSERT INTO test
(id,data1,data2,data3)
VALUES
(NULL,'".date("Ymd")."','1','".time()."')
");



then I wanted to use this information to populate another table is there a way of getting the Id value without doing a query SELECT to find the last row added to the table that has data1, data2 and data3 match and get the ID for it ?


Hope I've made sence here ?

DPoole
09-13-2003, 12:47 PM
erm think its this i need

http://uk.php.net/mysql_insert_id

wonder if it'll work with vb

Dean C
09-13-2003, 01:14 PM
Yes they use it in newthead.php and newreply.php :) (vb2)

DPoole
09-13-2003, 01:35 PM
haha, thanks mist, doh why didn't i think of this