Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003

    Question Unanswered: count rows in several "similar" tables

    I'm using table1 table2 table3 etc..

    what i want is to count all rows called 'pic'

    I'm currently using this soulution

    $result = mysql_query("SELECT pic FROM table1 UNION ALL SELECT pic FROM table2 UNION ALL SELECT pic FROM table3");
    $num_rows = mysql_num_rows($result);

    this way are getting to advanced to use when theres beeing added more tables.

    I'm wondering if theres a way like the one underneath that will work.. (i know the one underneath wont work, just use it to state a example) without doing a loop or something advanced

    $result = mysql_query("SELECT pic FROM `album*`");

    Thanks in advance
    Last edited by dalaker; 09-24-03 at 13:22.

  2. #2
    Join Date
    Sep 2003
    Not quite sure what you're asking but what you could do is a
    SHOW TABLES with mysql_exec and use a regex or something similar to find which tables match what tables you're looking for, fit each into an array and then do a loop on the array querying the tables... hopefully that's what you were asking...

Posting Permissions

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