Subject | Syntax for Union |
---|---|
Author | Steve Harp |
Post date | 2004-06-24T14:41:05Z |
Hi All,
I need some help with unions.
select Field1, Field2 from table1
union
select Field1, Field2 from table2
This works fine but I need to use the order by and where clauses on the
first table. Something I read suggested this.
(select t1.Field1, t1.Field2 AS Name from table1 t1
union
select t2.Field1, t2.Field2 AS Name from table2 t2)
where t1.Field3 = 'T'
order by Name
But this barfs on the initial '('. Can someone give me an example of a
union which can have where and order by clauses for the unioned tables?
Thanks,
Steve
[Non-text portions of this message have been removed]
I need some help with unions.
select Field1, Field2 from table1
union
select Field1, Field2 from table2
This works fine but I need to use the order by and where clauses on the
first table. Something I read suggested this.
(select t1.Field1, t1.Field2 AS Name from table1 t1
union
select t2.Field1, t2.Field2 AS Name from table2 t2)
where t1.Field3 = 'T'
order by Name
But this barfs on the initial '('. Can someone give me an example of a
union which can have where and order by clauses for the unioned tables?
Thanks,
Steve
[Non-text portions of this message have been removed]