Ashish Saxena
Ashish Saxena

Reputation: 426

How to apply pagination to the result of SHOW TABLES query in PHP

I would like to apply pagination to the results of SHOW TABLES FROM DATABASE_NAME.

Tried using the LIMIT keyword but an error is thrown.

By pagination I mean that the result(tables) returned by the query is to be displayed on multiple pages.

Upvotes: 13

Views: 17530

Answers (3)

ivke
ivke

Reputation: 321

mysql> pager less;

mysql> show tables;

Upvotes: 32

Mukesh
Mukesh

Reputation: 7778

You can try following

1)

SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES 
WHERE TABLE_SCHEMA = 'database_name' 
AND TABLE_NAME LIKE "a%" 
LIMIT 0,20;

2)

SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES 
WHERE TABLE_SCHEMA = 'database_name'  
LIMIT 0,50;

Upvotes: 0

Haim Evgi
Haim Evgi

Reputation: 125476

you can use the different query instead (an achieve the names of the tables) like:

    SELECT TABLE_NAME FROM information_schema.TABLES 
WHERE `TABLE_SCHEMA` = 'my_db_name' LIMIT 10

Upvotes: 22

Related Questions