SA-MP Forums Archive
MySQL combining - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL combining (/showthread.php?tid=651275)



MySQL combining - C5Perfect - 17.03.2018

SELECT * FROM `Houses`

and

select max(HouseID) FROM Houses

how can I combine these two?


Re: MySQL combining - MadeMan - 17.03.2018

Why?


Re: MySQL combining - Sithis - 17.03.2018

Assuming you are using an auto incremented primary key on the House table, why not do

SELECT * FROM `Houses` ORDER BY `HouseID` DESC LIMIT 1

or assuming you are saving a timestamp on the inserted datetime of the house

SELECT * FROM `Houses` ORDER BY `InsertedDateTime` DESC LIMIT 1


Re: MySQL combining - C5Perfect - 17.03.2018

Quote:
Originally Posted by Sithis
Посмотреть сообщение
Assuming you are using an auto incremented primary key on the House table, why not do

SELECT * FROM `Houses` ORDER BY `HouseID` DESC LIMIT 1

or assuming you are saving a timestamp on the inserted datetime of the house

SELECT * FROM `Houses` ORDER BY `InsertedDateTime` DESC LIMIT 1
Thank you!
is there a way to get the max unique id? So if I for example have 200 houses, and add one, then delete one it still would be 201, and next 202..?