A distinct join?

  • Hi,

    Can you create a join on a row but join it in such way that it acts like a distinct.

    Ie. Convert tthis statement to a join

    Select * from bbb

    Where number in (

    Select distinct number from aaa)

    Many thanks

  • Edward (7/2/2009)


    Hi,

    Can you create a join on a row but join it in such way that it acts like a distinct.

    Ie. Convert tthis statement to a join

    Select * from bbb

    Where number in (

    Select distinct number from aaa)

    Many thanks

    Would you like to provide us with the DDL for the tables and some sample data for them as well? The sample data should be in a readily consummable format so that it can be cut/paste/run to load the tables that you provide the CREATE TABLE statements (DDL) for.

    Also, for the above, as you aren't selecting anything from aaa, I wouldn't use a join. I'd actually use this:

    select

    *

    from

    bbb

    where

    exists(select 1 from aaa where aaa.number = bbb.number)

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply