Possible Duplicate:
Retrieve inserted row ID in SQL
Is there any way to get inserted rows id right after the insertion without doing select query? Basically, the idea is like this, I have two tables, one products, and second storage which has 3 columns - id / productId / count . And I need to insert in productId the product Id of the product which I inserted right before this query. So for example -
Product with id 1.
I insert it into a table for example products, it generates id 1. I don't do select, but right after I do another insert which will insert in table storage these data -
id - 1
/ productId - 1
(took from previous query which generated id 1 with AI) / count = 0
.
Hope you understood what I ment.
EDIT: I'm using MYSQL database.