all groups > sql server (alternate) > january 2006 >
You're in the

sql server (alternate)

group:

Advanced Sql-Shape Query - Help



Advanced Sql-Shape Query - Help doar123 NO[at]SPAM gmail.com
1/12/2006 1:43:24 PM
sql server (alternate): Hi,

This is my basic sql shape query:
------------------------------------------------------------
SHAPE {select * from tbl1}
APPEND({SELECT * FROM tbl2 where field1=1} AS RS2 RELATE field TO
field)
------------------------------------------------------------

With this query i get a RecordSet (RS1), who handle all the records
from table tbl1, and a secondary RecordSet (RS2) who handle all the
records from table tbl2, who applies to the criteria that field1=1.

It is possible that RS2 will be empty (zero records) since there is no
record in tbl2 who applies to that criteria.

My wish is to design a query, that will collect only the records from
tbl1, that will have records from tbl2 who applies to the criteria -
that RS2 won't be empty !

I want to influence on the main part of the query (RS1), through the
criteria that is being used in the secondery query (RS2).

I hope that my question is clear enough. thanks !
Re: Advanced Sql-Shape Query - Help Erland Sommarskog
1/12/2006 10:48:59 PM
(doar123@gmail.com) writes:
[quoted text, click to view]

If I get this right you want this in the SHAPE part:

SELECT * FROM tbl1
WHERE EXISTS (SELECT * FROM tbl2 WHERE tbl2.field = tbl1.fiedl)

--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
Re: Advanced Sql-Shape Query - Help doar123 NO[at]SPAM gmail.com
1/13/2006 1:08:34 AM
I didn't know i can use the exists query - I will check it out and get
back to report.

thanks for your help !
Re: Advanced Sql-Shape Query - Help doar123 NO[at]SPAM gmail.com
1/13/2006 1:19:27 AM
Well, It works like a charm !!!!

thank you !!!
AddThis Social Bookmark Button