如何使用PHP获取Mysql数据库中的最后一个字段? [英] How to get the last field in a Mysql database with PHP?

查看:163
本文介绍了如何使用PHP获取Mysql数据库中的最后一个字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有mysql数据库,我想从表中的字段获取最后一个ID。

I have mysql database and I want to get the last ID from field in a table .

示例: -

id   Value
1    david
2    jone
3    chris

如果此表存在,我想要一个函数返回3。

I want a function return 3 if this table exist .

推荐答案

想要选择具有AUTO_INCREMENT列的表中最近插入的行的ID,您将会感兴趣MySQL的 LAST_INSERT_ID 函数。

If you want to select the ID of the most recently inserted row in a table with an AUTO_INCREMENT column, you will likey be interested in MySQL's LAST_INSERT_ID function.

这篇关于如何使用PHP获取Mysql数据库中的最后一个字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆