Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想从表中获取最大 id。
如果我使用mysqli_insert_id,那么它会给出 0 值。请帮助或建议任何其他方法从表中获取最后/最大 id
mysqli_insert_id
$pre_id = $_POST['last_id']; $sql = mysqli_query($db3->connection, "SELECT * FROM chat where id=>_pre_id"); $id = mysqli_insert_id($db3->connection); echo $id;
那是你想要的吗?
SELECT * FROM chat ORDER BY id DESC LIMIT 0,1
试试这个查询
SELECT max(id) as maxid FROM chat