query

query

Post by Sunn » Sun, 17 Nov 2002 01:56:43



can i write a query like this..

select * from X where
X . a , X . b in (select a,b from C where <condition> )

regards
sunny

 
 
 

query

Post by Keith Kratochvi » Sun, 17 Nov 2002 02:13:22


Perhaps something along these lines will work for you:

SELECT X.*
FROM SomeTable X
INNER JOIN (select a,b from C where <condition> ) Y ON X.a = Y.a AND X.b =
Y.b

--
Keith, SQL Server MVP


Quote:> can i write a query like this..

> select * from X where
> X . a , X . b in (select a,b from C where <condition> )

> regards
> sunny


 
 
 

query

Post by Sunn » Sun, 17 Nov 2002 02:45:22


cool..
 i was looking if it was corect or not.. seems its gonna work the same way i
wanted..
thanks dude
sunny

Quote:> You can re-write this using EXISTS like:

> SELECT * FROM X
>  WHERE EXISTS (SELECT *
>                  FROM C
>                 WHERE C.a = X.a
>                   AND C.b = X.b
>                   AND ....)

> --
> - Anith

 
 
 

query

Post by Anith Se » Sun, 17 Nov 2002 02:35:24


You can re-write this using EXISTS like:

SELECT * FROM X
 WHERE EXISTS (SELECT *
                 FROM C
                WHERE C.a = X.a
                  AND C.b = X.b
                  AND ....)

--
- Anith

 
 
 

query

Post by Sunn » Sun, 17 Nov 2002 02:38:10


hi
the problem was..........

select * from X where
 X . a , X . b in (select a,b from C where <condition> )
------------
Can i write the above query like this.. ( i dont want to use joins as it is
a bit complex query only a part of which i had sent to you)
Will the below solution return the same results as i need in the above one

select * from X where
(exists (Select a, b from table1  w  where <condition1>  and  X.b = w.b  and
X.a = w.a ))

Thanks & regards
sunny



> Perhaps something along these lines will work for you:

> SELECT X.*
> FROM SomeTable X
> INNER JOIN (select a,b from C where <condition> ) Y ON X.a = Y.a AND X.b =
> Y.b

> --
> Keith, SQL Server MVP



> > can i write a query like this..

> > select * from X where
> > X . a , X . b in (select a,b from C where <condition> )

> > regards
> > sunny

 
 
 

1. Query using UDF joined to a sub query vs Temp Table to sub Query

I have a simple query question.  Currently I have a query that joins a UDF that returns a table to a sub query of a number of secondary tables.  This query seems to run forever, but if I dump the results of the udf into a temp table and use joined to the sub query the results are as expected.  Can anyone shed some light onto why?  Also is it possible to use the UDF in this manner with possible join hints to get the query return time I'm looking for?

2. stored procedure writing to a file

3. Query Query Query

4. msmq and ado recordset persistance

5. Query From Query Results

6. FL-Sarasota-OPM/Gemms Functional/Technical Resources

7. Subject: SQL Query - MAX, Grouping and Sub query

8. Output to printer

9. access query converted to sql7 query

10. Part of query in query result

11. Newbie: Access97 query to SQL Server 7 query

12. Simple queries versus complex queries

13. Query based on query