I use the query

SHOW TABLES LIKE 'users%' 

Tables look like users00001, users00002 And so on. Is it possible to somehow get the last created table, for example users01234. The problem is that there are no identifiers at the output. Is it possible at all, or what could be the solution? Thank you in advance

  • purely from the logic of sql sort in reverse order and display the very first. But how to do it with the tables, I do not know. - Vitaliy Shebanits

1 answer 1

Try this

 SELECT table_name, table_rows FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'forumNet' AND TABLE_NAME like "user%" ORDER BY TABLE_NAME DESC LIMIT 1 

Where forumNet is the name of your database.