Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2004
    Posts
    4

    Angry Unanswered: using two tables as one

    i have two tables with same structures and datatypes. One contains current data and other contains history data of the first one. I want to fetch records using both tables on some conditions without using procedures. Can I ?

  2. #2
    Join Date
    Mar 2001
    Location
    Lexington, KY
    Posts
    606
    Why can't you use UNION?
    Thanks,

    Matt

  3. #3
    Join Date
    Jul 2004
    Posts
    4
    Thanks MattR for reply..

    I have tried UNION , But my prob. is when i wnat to xtract data from these two tables and joining some more tables the UNION does'nt work

    Can u help

  4. #4
    Join Date
    Aug 2004
    Posts
    42
    Have you verified that the individual SELECTs in the UNION work independently? If so and simply adding the UNION keyword between them causes an error what kind of error:

    1. Complile time?
    2. Run time?
    3. Unexpected results? (perhaps some duplicate rows have been removed and yuo want UNION ALL?)

  5. #5
    Join Date
    Nov 2003
    Location
    Beijing
    Posts
    3
    You can place the union statement into a view, then you can do table join
    between this view and other tables.

  6. #6
    Join Date
    Jul 2004
    Posts
    4
    Union is not allowed in creating VIEW.

    The error is a syntax error when i try to join other tables and trying to use UNION for these two tables

  7. #7
    Join Date
    Nov 2003
    Location
    Beijing
    Posts
    3
    Union is not allowed in creating VIEW??? why?
    may be your ASE version is low.
    i execute below statement in my 12.5.1 ASE

    1> create table a1 (a int)
    2> go
    1> create table a2 (a int)
    2> go
    1> create view va(a) as
    2> select * from a1 union select * from a2
    3> go
    1> select * from a1, va where a1.a = va.a
    2> go
    a a
    ----------- -----------

    it seems OK!

  8. #8
    Join Date
    Mar 2001
    Location
    Lexington, KY
    Posts
    606
    You must have an old version of ASE. Why not join to each table.

    e.g.
    Code:
     select *
       from t1, join_table
      where t1.something = join_table.something
     union
     select *
       from t2, join_table
      where t2.something = join_table.something
    This should provide equivalent queries.
    Thanks,

    Matt

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •