On Monday 20 August 2001 23:59, Hans Zaunere wrote:
> Is there a way to have MySQL label columns returned
> from a select query with the complete column name, in
> table.column format?

AFAIK no.

<snip>

> Sure I could alias each column, but if there is 30
> columns, that's a lot of aliasing.  Is there a way to
> alias a whole table, so each returned column is
> prefixed by a specified string?

What I usually end up doing is setting an abbreviation for each table and 
prefix each column name with this abbreviation, e.g. (*)

  CREATE TABLE customer (
     c_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
     c_name VARCHAR(100)
  )

  CREATE TABLE customer_address (
     ca_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
     ca_c_id INT UNSIGNED NOT NULL,
     ca_street VARCHAR(100)
  )

  SELECT c.*, ca.*
    FROM customer c, customer_address ca
   WHERE ca.ca_c_id = c.c_id

The table abbreviations end up doubled :-( but this guarantees the 
application gets unique table names and avoids the hassle of aliases.

HTH

Ian Barwick



(*) Disclaimer: example code, may not be accurate, use at own risk ;-)

-- 
Ian Barwick - Developer - [EMAIL PROTECTED]
akademie.de asp GmbH - http://www.akademie.de

"To query tables in a MySQL database is more fun than eating spam"

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to