|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Sunday, May 25, 2008 11:04 PM
Points: 30,
Visits: 11
|
|
Hi there Gurus!
I thought I was a naive beyond imagination 'cos I completely missed the purpose of that query! Looks like something framed on a particularly boring afternoon :)
We need better than that if we are to learn!
The naïveté
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: 2 days ago @ 12:34 AM
Points: 449,
Visits: 1,772
|
|
Hi There,
I agree that the query would work, but only on the premise that only one of the tables had the column customerid. To say that any of the two tables could have the customerid would require having an alias to resolve the column.
My 2 cents
:)
Regards,
WilliamD
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: 2 days ago @ 2:52 PM
Points: 1,322,
Visits: 1,071
|
|
I don't think that the fact that the query compiles is a bug per se. It compiles because subqueries must have access to their parent in order to create correlated queries. The compiler can't assume what that correlation is going to look like so if it can resolve the name it will. Think of:
select Count(*) FROM ClientTable where Exists (SELECT * FROM OrderTable where PKClientID = FKClientID)
Now, while I consider it bad to have different names for the same information, I 've seen this type of design. The Compiler must be able to compile the above because it is valid. Therefore it also must be able to compile the syntactically correct, but bizarre: select * from ClientTable, Contracts Where clientid in (select contractclientid where overdue > 30)
As far as the compiler is concerned as long as the names contractclientid and overdue are resolvable then it is a syntactically valid statement. -- JimFive
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Wednesday, May 23, 2012 6:06 PM
Points: 40,
Visits: 3
|
|
Query
What will happen if following query get executed:
select CategoryID, Quantity, Price from Customer c, SalesOrderDetail sod where sod.clientid in (select customerid where pricingplan='X')
In this Query options nothing was spoken about pricingplan column. If pricingplan column is not part of either of the tables then the query will end up in Error. Why not the Third option is right answer for this Question in this scenario?? :)
|
|
|
|