简体   繁体   中英

how to add value this MAX number

This is my SQL query.

$max_Number = DBGet(DBQuery("SELECT MAX(student_id) FROM students"));

When I print as array in PHP . This array appear like this. print_r($max_Number);

Array ( [1] => Array ( [MAX(STUDENT_ID)] => 4436 ) )

I want add 1 for the 4436 this value in php. how to do that.please help me

Add 1 in a query:

SELECT MAX(student_id) + 1 as `max` FROM students

Though I don't know why you need to increment student_id , but if your case is to add new item with the next id - you're doing it wrong . Instead - set student_id as AUTOINCREMENT .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM