   [web] SQL Help -Stored Procedures
  Hello,I'm trying to build a stored procedure that inserts some rows into a couple tables..we'll call them table1 and table2The problem is I need to know the Primary ID of the record that I insert into table1 in order to insert my second record into table2..For example I have this right nowINSERT INTO table1 (name, value) VALUES ('kag1' , 'value1')after inserting that record do I have to SELECT it again in order to get the ID of it? (The ID is an integer that increments 1 every record)and then after I get that ID i wanted to go likeINSERT INTO table2 (table1_ID, name, value) VALUES (@ID, 'kag1' ,' value2')I know such a thing is possible...I just can't find out how to do it..Thanx kag1   
  If you are using MS Sql Server or Sql Express you can use the SELECT @@IDENTITY after the insert to retrieve the last Primary Key inserted in the table.  For the other databases, I am not aware. HTH   ;  If you're using MySQL and PHP you can use mysql_insert_id.   ;  On a related note, just how reliable is mysql_insert_id() ?  I have used it for several scripts, and I've noticed that sometimes it picks up a zero or null value for the auto-increment column.   