user2613707
user2613707

Reputation: 79

Show all tables from my database but one?

I want to show all the tables from my database but one . Now i know that the obvious way to do it would be like the following :

<?php
   $query = "SHOW TABLES";
   $result= mysql_query($query ) or exit(mysql_error());
   while ($row = mysql_fetch_row($result)) {
     if ($row[0] != 'THE UNWANTED TABLE NAME') {
       echo '<option value="'.$row[0].'">'.$row[0].'</option>';
   }
 }
?>

MY question : Is there any way to do this only via query, something like this :

$query = "show tables where 'condition to exclude the unwanted table' " 

?

Thanks

Upvotes: 0

Views: 148

Answers (2)

Prix
Prix

Reputation: 19528

 SHOW TABLES 
 FROM mydatabase 
WHERE Tables_in_mydatabase != 'THE UNWANTED TABLE NAME';

See more about SHOW TABLES; syntax here.

Replace mydatabase with your database name.

Upvotes: 1

fejese
fejese

Reputation: 4628

You can look at the documentation: http://dev.mysql.com/doc/refman/5.0/en/show-tables.html You can use:

SHOW [FULL] TABLES [{FROM | IN} db_name] [LIKE 'pattern' | WHERE expr]

Upvotes: 1

Related Questions