www.webdeveloper.com
Results 1 to 3 of 3

Thread: List tables that have specific string

  1. #1
    Join Date
    Nov 2010
    Posts
    56

    List tables that have specific string

    Hi all,

    I am wanted to list tables from my database, but only tables that contain a certain string.
    Say I have a database with four tables:
    honda_car
    yamaha_bike
    kawasaki_bike
    ford_car
    I want to be able to list all tables that contain 'car'.

    Any help is greatly appreciated

    Josh

  2. #2
    Join Date
    Nov 2010
    Posts
    56
    After more searching, I found what I am looking for. In case anyone else find this when trying to do the same thing:
    PHP Code:
    $sql "SHOW TABLES FROM demonsi1_db LIKE '%_gallery'";
    $do_sql mysql_query($sql);
    while(
    $row mysql_fetch_array($do_sql))
    {
        echo 
    $row['0'] . "<br>";


  3. #3
    Join Date
    Oct 2009
    Posts
    658
    In asking for help on databases I always advise to indicate what database you are using.
    In MS SQL you have

    Code:
    USE <DATABASE>
    SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '<SCHEMA>' AND TABLE_NAME LIKE '&#37;<STRING>%'
    Good Luck

    Santos Systems

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles