Complex SQL Statement

Meeting place for R&R customers and clients to share tips and ideas. Post your questions, messages or problems here.
Post Reply
MarkB_(Guest)
Posts: 3
Joined: Tue Oct 10, 2017 12:44 pm

Complex SQL Statement

Post by MarkB_(Guest) » Tue Oct 10, 2006 5:53 pm

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

kfleming
Posts: 5795
Joined: Tue Oct 10, 2017 12:44 pm

=> RE: Complex SQL Statement

Post by kfleming » Wed Oct 11, 2006 10:05 am

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

MarkB_(Guest)
Posts: 3
Joined: Tue Oct 10, 2017 12:44 pm

==> RE: Complex SQL Statement

Post by MarkB_(Guest) » Wed Oct 11, 2006 10:22 am

The question is how to enter the "EXISTS" statement into the R&R query builder.____Mark

MarkB_(Guest)
Posts: 3
Joined: Tue Oct 10, 2017 12:44 pm

===> RE: Complex SQL Statement

Post by MarkB_(Guest) » Wed Oct 11, 2006 11:41 am

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

kfleming
Posts: 5795
Joined: Tue Oct 10, 2017 12:44 pm

====> RE: Complex SQL Statement

Post by kfleming » Wed Oct 11, 2006 3:55 pm

Thanks for the update.____Kathleen__R&R Support

Post Reply