List:General Discussion« Previous MessageNext Message »
From:<sinisa Date:March 16 1999 12:14am
Subject:returning table name
View as plain text  
Marc Antony Vose writes:
 > Hey there.
 > 
 > This may be an elementary question, and if so, I apologize, but I can't
 > seem to find a reference to it in my book or the MySQL manual.  I'm new at
 > SQL.
 > 
 > I'm running a games site off MySQL, and I've got three tables: games,
 > hardware and utilities.
 > 
 > I want to query all three tables at once and return "upcoming products".
 > The problem is, I need to distinguish between games, hardware and
 > utilities, but I want it in one list.
 > 
 > So, I'd like it to return the table name along with each row, like so:
 > 
 > name         table
 > 
 > Baseball     games
 > Blah Blah    utilities
 > Joystick X   hardware
 > Quake        games
 > 
 > Is this possible?
 > 
 > Cheers.
 > 
 > 
 > Marc Antony Vose
 > Founder, Mac Game Database
 > http://www.gamedb.com/
 > 

Hi!

No, it is not possible, you must have three queries. In  any SQL the
same field name, like 'name', used by three table would in a single
query produce 'ambiguous field name' error.

Sinisa

+---------------------------------------------------------------------+
| TcX  ____  __     _____   _____  ___        ==  mysql@stripped        |
|     /*/\*\/\*\   /*/ \*\ /*/ \*\ |*|        Sinisa Milivojevic      |
|    /*/ /*/ /*/   \*\_   |*|   |*||*|        mailto:sinisa@stripped |
|   /*/ /*/ /*/\*\/*/  \*\|*|   |*||*|        Belgrade                |
|  /*/     /*/  /*/\*\_/*/ \*\_/*/ |*|_____   Serbia                  |
|  ^^^^^^^^^^^^/*/^^^^^^^^^^^\*\^^^^^^^^^^^                           |
|             /*/             \*\                   Developers Team   |
+---------------------------------------------------------------------+
Thread
File access problemtymiwi14 Mar
  • File access problemMichael Widenius15 Mar
  • Re: File access problemVan15 Mar
    • returning table nameMarc Antony Vose15 Mar
      • returning table namesinisa16 Mar
        • Re: returning table nameThimble Smith16 Mar
Re: File access problemMikael Willberg15 Mar
Re: returning table nameefrazier16 Mar
  • Re: returning table nameThimble Smith16 Mar