how to select last_insert_id?

user123456789

I have an sql statement that returns more than one value: enter image description here

In my code I then need to call the last ID that was inserted. I have seen some examples about SELECT LAST_INSERT_ID() but they all seems to be for insert statements. I just want to show the last inserted id.

So from the image below I would only need to select ID 13

Ullas

Use ORDER BY and LIMIT .

Query

SELECT dl.* FROM driver_log dl
WHERE dl.Company_ID = 76 AND dl.Manifesr=tNo = 8199
ORDER BY ID DESC LIMIT 1;

If you want to select only the ID, then use MAX function.

SELECT MAX(dl.ID) as ID 
FROM driver_log dl
WHERE dl.Company_ID = 76 AND dl.Manifesr=tNo = 8199;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

SELECT LAST_INSERT_ID() not generating correctly

From Dev

SELECT LAST_INSERT_ID() returning zero

From Dev

SQL, select last insert ID by LAST_INSERT_ID()

From Dev

How efficient is Last_insert_id?

From Dev

Thread safety of MySQL's Select Last_Insert_ID

From Dev

Using select last_insert_id() from php not working

From Dev

How to do a multiple insert using LAST_INSERT_ID() MySQL?

From Dev

How to do a multiple insert using LAST_INSERT_ID() MySQL?

From Dev

MySQL LAST_INSERT_ID() - how does it works

From Dev

how to get LAST_INSERT_ID via stored procedure in php

From Dev

MYSQL LAST_INSERT_ID not working as intended. How do I fix?

From Dev

How to store LAST_INSERT_ID() in database as foreign key in another table

From Dev

How to use LAST_INSERT_ID() when using uuid as a default value?

From Dev

MYSQL last_insert_id() and concurrency

From Dev

LAST_INSERT_ID after restarting MySQL

From Dev

MYSQL last_insert_id() and concurrency

From Dev

use of where cluase for last_insert_id

From Dev

Java Spring JDBC last_insert_id()

From Dev

MariaDB Columnstore LAST_INSERT_ID() alternative

From Dev

SQL Add a prefix to LAST_INSERT_ID()

From Dev

How to select the last record of each ID

From Dev

In SQLite, how to insert an id field in select result?

From Dev

How not to select the last element

From Dev

Invalid descriptor index on LAST_INSERT_ID after insert

From Dev

INSERT INTO double select - how?

From Dev

Is it possible to get LAST_INSERT_ID() from different database?

From Dev

MySQL : Stored procedure returns null for last_insert_id

From Dev

MySQL retrieve last_insert_id from stored procedure

From Dev

MySQL: Can't get LAST_INSERT_ID()

Related Related

HotTag

Archive