homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Seeking for MySQL tables by regex
There's got to be a way to do this, but I can't find it

 12:39 am on Apr 3, 2008 (gmt 0)

I've got a MySQL database with a little over 400 tables in it. I'm writing a script that needs to access about ten of these. The trouble is that those ten tables have what you might call dynamic titles, meaning they're created by other scripts periodically. This means I can't just hard-code the table names into my current script.

The tables in question do follow a consistent naming scheme - specifically, a three-letter word (they share the same one), followed by a random, unique, nine-digit number. No other tables in the database share this naming pattern.

How can I use PHP to scan the database for all tables that fit that pattern, without causing too much overhead?

Thanks in advance,




 1:38 am on Apr 3, 2008 (gmt 0)

I was able to do this successfully:
SHOW TABLES WHERE Tables_in_database_name REGEXP '^f.*'

And I got the table names starting with f.
Alternatively you could use show tables to get them all into an array to regex them.


 12:00 pm on Apr 3, 2008 (gmt 0)

when these dynamicly created tables are created just insert a row into a table that tracks thease dynamicly created tables.

have some sproc's that handle the dymincly created tables and handels the inserts/deletes etc

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved