Skip to content
Advertisement

How do store a list of sorted tables with an SQL SHOW TABLES statement?

I am using the following code to show all tables, but how do I store the tables into a sorted array:

The following code spits out the data:

Advertisement

Answer

Put the table names in a PHP array, and then sort the array. And if you don’t nest it in the row, you don’t need nested loops when you process it.

You can’t use ORDER BY with SHOW TABLES, but you can use LIKE to select only tables that fit a pattern. Then you don’t need the if statement in your loop.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement