On Fri, Sep 4, 2009 at 7:19 PM, Nancy Wichmann <nan_wich@bellsouth.net> wrote:
Ivan Sergio Borgonovo wrote:
> A better way would be to learn how to query information_schema that
> *should* be portable.

Well, I don't know about portable, but the MySql manual is wrong in its
comparison.
 $list = array();
 $result = db_query("SHOW TABLES LIKE 'abc\_%'");
 while ($table = db_result($result)) {
   $list[] = $table;
 }

Worked just fine. However, to make it work with information_schema required:
 $list = array();
 $result = db_query("SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE
table_name LIKE 'abc\_%'");
 while ($table = db_fetch_array($result)) {
   $list[] = $table['table_name'];
 }
 $list = array_unique($list);
 sort($list);

Note that the list had MANY duplicates in it and did not come out in order
of table name.


This is plain SQL, and hence there is nothing stopping you from using DISTINCT as well as ORDER BY, like any other SQL. It should be portable between MySQL and PostgreSQL.
--
Khalid M. Baheyeldin
2bits.com, Inc.
http://2bits.com
Drupal optimization, development, customization and consulting.
Simplicity is prerequisite for reliability. --  Edsger W.Dijkstra
Simplicity is the ultimate sophistication. --   Leonardo da Vinci