Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2004
    Posts
    31

    Unanswered: Merge two fields from two different tables into one

    If possible, I would like to create a view using two different tables, but with the fields merged (ie. create one table from two tables). The table structures are pretty much the same. Can you do this from a singe SQL statement? Any ideas? My only alternative is creating a temp file that inserts records from both tables, but I want to avoid doing that.

  2. #2
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    TableA (KeyField ..., f1 varchar(...), f2 varchar(...))
    TableA (KeyField ..., f1 varchar(...), f2 varchar(...))
    __________________________________

    create view vw_OneTableFromTwo (f1, f2) as
    select a.f1+b.f1, a.f2+b.f2
    from TableA a
    inner join TableB b
    on a.KeyField=b.KeyField
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

  3. #3
    Join Date
    Feb 2004
    Posts
    25

    Question what you want

    you have two tables :

    Table1
    Key1
    F1
    F2

    Table 2
    Key2
    F3
    F4

    and you want a table:

    Table3
    F2
    F4
    where Key1 = Key2

    it's what you want?

  4. #4
    Join Date
    Jun 2004
    Posts
    31
    Thanks for the input, but that's not what I need. I don't think I expained myself very well. There are two tables with the same fields, but different data in them. The data is actually air sample date. The difference between the two tables are that one is preliminary data (didn't pass through quality control) and one is final. I want to have a view that appends one table to another. For example:

    Table 1 (fields): T1.Date, T1.SampID, T1.Concentration, T1.FlagCode.

    Table2(fields): T2.Date, T2.SampID, T2.Concentration, T2.FlagCode.

    The View I want to Create (all records from both tables):
    VW: Date, SampID, Concentration, FlagCode


    Please help!!!!

  5. #5
    Join Date
    Feb 2004
    Posts
    492
    er, UNION ?

  6. #6
    Join Date
    Jun 2004
    Posts
    31
    Damn! That was simple enough. Thanks.

  7. #7
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    Would that not be a Union All
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

Posting Permissions

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