Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2003
    Posts
    5

    Unanswered: Multiple view from a single select statement

    Hi,
    I want to write an SQL query which should return me 2 kinds of outputs depending on which condition is true. i.e.

    the query should be something like

    select someview if (condition1 = true)
    else select someotherview if (condition2 = true)

    where someview is a set of columns from one table only, and someotherview is a set of columns which is a superset of someview (& is generated from two tables, which have no common field)

    Let me explain this further --
    I want to select data from one table and a single field from other table, however if I the first table does not return any data, I still want data from the other table to be returned.
    Can I write a SQL query to do this?

    -- Amit

  2. #2
    Join Date
    Dec 2003
    Posts
    74
    do a union query.

    select * from table1
    union
    select 'ed' from table2;

    if table 1 is return not rows table2 will still return data.

    Does this answer your question?

  3. #3
    Join Date
    Dec 2003
    Posts
    5
    Originally posted by edwinjames
    do a union query.

    select * from table1
    union
    select 'ed' from table2;

    if table 1 is return not rows table2 will still return data.

    Does this answer your question?

    I know, that I can use a union, however I want to support TimesTen & Oracle using thsame query...TT does not allow union while oracle does, can I write another query which emulates union?

  4. #4
    Join Date
    Dec 2003
    Posts
    74
    I am sorry I am not farmiliar with TT.

    Does it support outer joins?

  5. #5
    Join Date
    Dec 2003
    Posts
    5
    Originally posted by edwinjames
    I am sorry I am not farmiliar with TT.

    Does it support outer joins?

    Yes it dows, hence I am now using outer joins

  6. #6
    Join Date
    Dec 2003
    Posts
    74

    Talking

    Glad to be of help


Posting Permissions

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