Page 1 of 1

Complex SQL Statement

Posted: Tue Oct 10, 2006 5:53 pm
by MarkB_(Guest)
Is there a way to use the "EXISTS" in the where clause of a SQL statement?____select * from table 1 __where exists (select * from table 2 where table2.xxx = table1.xxx)____TIA__Mark

=> RE: Complex SQL Statement

Posted: Wed Oct 11, 2006 10:05 am
by kfleming
I just tried this User SQL against the SQL Server pubs sample database using the Microsoft SQL Server driver and it worked without a problem.______select * from dbo.publishers __where exists__(SELECT * from dbo.pub_info where publishers.pub_id = pub_info.pub_id )______Kathleen__R&R Support

==> RE: Complex SQL Statement

Posted: Wed Oct 11, 2006 10:22 am
by MarkB_(Guest)
The question is how to enter the "EXISTS" statement into the R&R query builder.____Mark

===> RE: Complex SQL Statement

Posted: Wed Oct 11, 2006 11:41 am
by MarkB_(Guest)
As it turnes out it was not the "EXISTS" part of the statement that was causing the error. I zeroed in on that as it was the only thing complex in the statement. ____In fact the problem turned out to be the handling of the following which I omitted from the first post as I did not suspect it.____select field1 as billed_amt____The parser cannot handle the as clause. Removing that clause and the query worked fine. Sorry for the misdirection but I thought I would send this to document the behavior for others.____Mark

====> RE: Complex SQL Statement

Posted: Wed Oct 11, 2006 3:55 pm
by kfleming
Thanks for the update.____Kathleen__R&R Support