|
Home > Archive > MS SQL Server MSEQ > July 2005 > Comparing a pair
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Gaz uk 2005-07-14, 9:23 am |
| Hi
I would like to have a subquery where I'm comparing 2 values from the
subquery to the main query and unsure on the syntax. I know in Oracle sql
it's something like
WHERE (manager_id , dept_id) IN (SELECT manager_id, dept_id FROM table ...
etc)
Thanks in advance for your help
G
| |
| David Portas 2005-07-17, 8:24 pm |
| TSQL doesn't have row-value constructors. But EXISTS is often a better way
than using IN anyway:
SELECT *
FROM Foo
WHERE EXISTS
(SELECT *
FROM Bar
WHERE bar.manager_id = foo.manager_id
AND bar.dept_id = foo.dept_id)
--
David Portas
SQL Server MVP
--
| |
| Gaz uk 2005-07-19, 9:23 am |
| ok, will try. thanks
"David Portas" wrote:
> TSQL doesn't have row-value constructors. But EXISTS is often a better way
> than using IN anyway:
>
> SELECT *
> FROM Foo
> WHERE EXISTS
> (SELECT *
> FROM Bar
> WHERE bar.manager_id = foo.manager_id
> AND bar.dept_id = foo.dept_id)
>
> --
> David Portas
> SQL Server MVP
> --
>
>
>
|
|
|
|
|