Results 1 to 3 of 3

Thread: [RESOLVED] subquery problem thanks for help

  1. #1

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Resolved [RESOLVED] subquery problem thanks for help

    Hi all,

    I have 3 tables.

    I want select data from 1 of the table but and using subquery to select another 2 value from another 2 tables.

    actually i want to do a comparison if table A Type = 'E' then select from Table B if Type ='S' select from Table C.

    How do I accomplish this ?

    Thanks a million!
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: subquery problem thanks for help

    Which database? What are the table structures? Can they be linked?

    If TableA can be linked to Tables B and C, then simple Left Joins would work.

    In SQL Server you could also use something like

    Select Case Type
    When 'E' Then (Select....)
    When 'S' Then (Select...)
    Else Null End As ColumnName,
    Other Columns...
    From TableA

  3. #3

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: subquery problem thanks for help

    Thanks bruve you solved my problem but I need to put a "(" before select and ")" after End.

    really appreciate....

    (Select Case Type
    When 'E' Then (Select....)
    When 'S' Then (Select...)
    Else Null End) As ColumnName,
    Other Columns...
    From TableA
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

Posting Permissions

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



Click Here to Expand Forum to Full Width