jeanluca has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I've this simple perl script that only needs to do is to select specific tables. For example I've tables like:
table1_2004_12 table2_2005_01 .......
I noticed that a request like: show tables LIKE 'table%' works. But I like to be more specific, so I tried:show tables RLIKE 'table\d+_\d{4}_\d{2}', which didn't work at all.
Any suggestion how to do this ??

Thanks a lot
Luca

ps. If this is a question that shouldn't be posted on this site, where can I find a good mysql forum ?

Replies are listed 'Best First'.
Re: Mysql: select specific tables
by rnahi (Curate) on Nov 24, 2005 at 07:55 UTC

    If you use MySQL 5, you can query information_schema.tables with the full force of SQL.

    But, as you suspect, your question is OT here.

    Have you seen http://forums.mysql.com?

Re: Mysql: select specific tables
by kulls (Hermit) on Nov 24, 2005 at 08:27 UTC
    Hi,
    I guess u missed the database name in the query. check the sytanx here
    -kulls
      I looked at Show table syntax but that doesn't help very much!!
      No I have
      SHOW TABLES FROM myDB LIKE '^tables_\d+_\d{4}_\d{2}$'
      doesn't return anything...
      MySQL uses Perl regexp right ?

      Thanks
      Luca
        yes.
        you're correct.
        if you look into pattern matching , they mentioned that, " I believe that what you have in your example is a PERL extension which is not part of the POSIX specification for regular expressions and is not important unless you need to extract the matched substrings (which is not the case)."
        -kulls
Re: Mysql: select specific tables
by EvanCarroll (Chaplain) on Nov 24, 2005 at 09:09 UTC
    my @tables = grep m/table\d+_\d{4}_\d{2}/, @{$dbh->tables};
    DBI DBH Methods


    Evan Carroll
    www.EvanCarroll.com