Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

can't retrieve auto_increment value from t1.f1 and put in t2.f1

timothy.waterstimothy.waters Member Posts: 1
Hello all,
I'm having a real time trying to get this last part of a school project done. I'm writing in java using jdbc and mysql. Quite simply here is the problem:
I have a table where the primary key is auto_increment and it's name is InvoiceNumber. I have another table that contains that same field, however it cannot auto_increment because it is a one-to-many relationship. so, I need to get the last InvoiceNumber created from Invoices.InvoiceNumber and put it in InvoiceItems.InvoiceNumber. However I have tried last_insert_id() and that just returns zero's and has been no help. The insert statement for the Invoices table works just fine. In my thinking this should not be difficult and it's killing me that I've spent so much time trying to get this one thing working when it should be a very common thing to do.
Sign In or Register to comment.