Subject | Re: [firebird-support] Re: Combine 2 tables |
---|---|
Author | Arno Brinkman |
Post date | 2004-06-07T12:34:02Z |
Hi,
SELECT
SomeName AS Field1,
SomeOtherStuff AS Field2
FROM
Table1
UNION ALL
SELECT
OtherName,
CAST(NULL AS VarChar(35))
FROM
Table2
Regards,
Arno Brinkman
ABVisie
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird open source database (based on IB-OE) with many SQL-99 features :
http://www.firebirdsql.org
http://www.firebirdsql.info
http://www.fingerbird.de/
http://www.comunidade-firebird.org/
Support list for Interbase and Firebird users :
firebird-support@yahoogroups.com
Nederlandse firebird nieuwsgroep :
news://newsgroups.firebirdsql.info
> > You can do that with UNION ALL :Just cast a literal value or NULL to the same datatype :
> >
> > SELECT
> > SomeName AS Field1,
> > SomeOtherStuff AS Field2
> > FROM
> > Table1
> > UNION ALL
> > SELECT
> > OtherName,
> > SomeOtherStuff
> > FROM
> > Table2
>
> Thanks, looks like what i need, but what if i also need to get a field
> that is in only 1 table?
> I get the following error: -count of column list and variable list do
> not match
>
> How can i do this?
SELECT
SomeName AS Field1,
SomeOtherStuff AS Field2
FROM
Table1
UNION ALL
SELECT
OtherName,
CAST(NULL AS VarChar(35))
FROM
Table2
Regards,
Arno Brinkman
ABVisie
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird open source database (based on IB-OE) with many SQL-99 features :
http://www.firebirdsql.org
http://www.firebirdsql.info
http://www.fingerbird.de/
http://www.comunidade-firebird.org/
Support list for Interbase and Firebird users :
firebird-support@yahoogroups.com
Nederlandse firebird nieuwsgroep :
news://newsgroups.firebirdsql.info