In MSSQL there is a command called SCOPE_IDENTITY() which returns the id of the 
last inserted row. There is probably something similar in whatever dbms you are 
using.

Otherwise I would need some more information about our environment.


Freundliche Grüsse / Best Regards / Meilleures salutations
Adrian Stern

From: interest-bounces+adrian.stern=screenfood....@qt-project.org 
[mailto:interest-bounces+adrian.stern=screenfood....@qt-project.org] On Behalf 
Of Witold E Wolski
Sent: 22 May 2013 10:26
To: interest@qt-project.org
Subject: [Interest] "Last selected row id" QSqlQuery?

How can I get efficiently the id of the last insterted row?
A the moment I am using :
SELECT MAX(id) from table.
Which isn't efficient.

How can i do it more efficiently but stay database agnostic.
best
Witold

Diese E-Mail und ihre Anhänge enthalten vertrauliche und/oder rechtlich 
geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese 
E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und 
vernichten Sie diese Mail inklusive Anhänge. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe der Inhalte dieser Mail ist nicht gestattet.
This e-mail and any attachments may contain confidential and/or privileged 
information. If you are not the intended recipient (or have received this 
e-mail in error) please notify the sender immediately and destroy this e-mail 
including the attachments. Any unauthorized copying, disclosure or distribution 
of the material in this e-mail is strictly forbidden.
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to