[Interest] "Last selected row id" QSqlQuery?

Adrian Stern adrian.stern at screenfood.com
Wed May 22 10:29:59 CEST 2013

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.com at qt-project.org [mailto:interest-bounces+adrian.stern=screenfood.com at qt-project.org] On Behalf Of Witold E Wolski
Sent: 22 May 2013 10:26
To: interest at 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.

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130522/7677b83e/attachment.html>

More information about the Interest mailing list