Search code examples
phpmysqlsqlmysqli

How to list all tables in a database with MySQLi


I have looked around and still can't find how to list all my tables in a database. Is it possible with MySQLi?


Solution

  • There are many ways.

    SHOW TABLES
    

    Is the most simple SQL statement for doing that. You can also take a look at INFORMATION_SCHEMA.TABLES if you want to have more details or do some filtering or such.

    SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA LIKE 'your_database';