[英]how to get the last value in the non auto incremented id?
I am using two IDs DM_ID and id. 我正在使用两个ID DM_ID和ID。 DM_ID is auto incremented while id is not.
DM_ID自动增加,而id不自动增加。 I want to get the last value of id.
我想获取id的最后一个值。 I used mysqli_insert_id() to get it but i get the last of DM_ID.
我使用mysqli_insert_id()来获取它,但我得到了DM_ID的最后一个。 DM_ID and is in one table.
DM_ID,位于一个表中。
You need to fire a query to get that, 您需要执行查询才能获取该信息,
SELECT MAX(`id`) from `tbl_name`
Or if you need id
of last inserted record, 或者,如果您需要最后插入的记录的
id
,
SELECT `id` from `tbl_name` where `DM_ID` = mysqli_insert_id()
这样尝试
select id from tablename order by DM_ID desc limit 1
SELECT id from tablename order by DM_ID desc limit 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.