From: Dan Nelson
Date: August 29 2002 3:28am
Subject: Re: Join with Union
List-Archive: http://lists.mysql.com/mysql/118313
Message-Id: <20020829032830.GB4308@dan.emsphone.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
In the last episode (Aug 29), suresh said:
> I changed from mysql 3.23.49 -nt to 4.0.2 max to make use of union
>
> But one problem when trying to join tables is that UNION works only
> for SELECT queries with same number of coulmns. Is there any way to
> join 3 or more tables having different columns using UNION? I am
> writing my query during the runtime. Since the user can select any
> number of fileds from a particular table and also I am using LEFT
> JOIN, I can't make all the tables having same number of fields.
You can easily add dummuy colums to the queries that are missing
columns.
SELECT name, "N/A" from table1
UNION
SELECT name, address from table2;
--
Dan Nelson
dnelson@stripped