create table foo(id, val1)
create table foo_bars(id, foo_id, val2)
id is auto generated in the above case.
I want to do the following
insert into foo (val1) values (1)
insert into foo_bars (foo_id, val2) values (?, 2)
How do I fetch the value of foo_id if its not known to me. Do I need to hard-code these id(s) also. Is there an elegant way?
According to the mysql site (http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html)
Try this (if you want to use pure MySQL):