Unix Technical Forum

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

This is a discussion on select * from a where (field1fromA, field2fromA) in (1,1) within the SQL Server forums, part of the Microsoft SQL Server category; --> Hello! You can do it in Oracle, but how to do that in MS SQL. I don't whish to ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 02:34 AM
bdjensen
 
Posts: n/a
Default 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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 02:34 AM
Hugo Kornelis
 
Posts: n/a
Default Re: select * from a where (field1fromA, field2fromA) in (1,1)

On Thu, 22 Apr 2004 10:21:43 +0200, bdjensen wrote:

>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
>


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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:22 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com