select * from a where (field1fromA, field2fromA) in (1,1)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bdjensen

    select * from a where (field1fromA, field2fromA) in (1,1)

    Hello!
    You can do it in Oracle, but how to do that in MS SQL.
    I don't whish to write

    select * from a where field1fromA=1 and field2fromA=2

    because i want to generate (1,1) from a subselect...

    Thanks
    Bjoern


  • Hugo Kornelis

    #2
    Re: select * from a where (field1fromA, field2fromA) in (1,1)

    On Thu, 22 Apr 2004 10:21:43 +0200, bdjensen wrote:
    [color=blue]
    >Hello!
    >You can do it in Oracle, but how to do that in MS SQL.
    >I don't whish to write
    >
    >select * from a where field1fromA=1 and field2fromA=2
    >
    >because i want to generate (1,1) from a subselect...
    >
    >Thanks
    >Bjoern
    >[/color]

    Hi Bjoern,

    You can change the IN to an EXISTS:

    Illegal in SQL Server:

    SELECT something
    FROM a
    WHERE (field1, field2) IN
    (SELECT col1, col2
    FROM othertable
    WHERE whatever = something)

    Equivalent, legal in SQL Server:

    SELECT something
    FROM a
    WHERE EXISTS
    (SELECT *
    FROM othertable
    WHERE whatever = something
    AND col1 = a.field1
    AND col2 = a.field2)


    Best, Hugo
    --

    (Remove _NO_ and _SPAM_ to get my e-mail address)

    Comment

    Working...