PDA

View Full Version : MySQL-LabView8.0 select last_insert_id


Nighthunter
10-09-2006, 07:47 AM
Hello,
I'm making a measuring program based on LabView 8.0, the results of measurements are saved into MySQL database.

The problem is when I'm inserting datas into MySQL I want to know into which line the measurement is been saved. So I used the LAST_INSERT_ID, but all what I'm getting back is 0.

When I tried this in MySQLCC this worked just fine.

Thank you

Rok

guelphdad
10-09-2006, 08:08 AM
you can only use last_insert_id when you are inserting into a table that has an auto increment field. without it you won't. the secondary table does not have to have an auto increment column.

Nighthunter
10-09-2006, 08:27 AM
ups...
I forgot to tell, yes I haave an auto increment field. And tnd Insert_last_id(), the problem is because i can't get that ID into LabView.

( I have a few inserts and selects between MySQL and LV, but this is the only one which is making a problem)

guelphdad
10-09-2006, 02:43 PM
if you do any inserts in between the one with the table with the auto increment and the one where you are using that variable then set it in a variable.

See this article (http://www.guelphdad.wefixtech.co.uk/sqlhelp/lastinsertid.shtml) for more info on using last_insert_id.