SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Query


Query

Author
Message
Rajani Poduval
Rajani Poduval
SSC Rookie
SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)

Group: General Forum Members
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 Smile

We need better than that if we are to learn!

The naïveté
w.durkin@online.de
w.durkin@online.de
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1081 Visits: 1879
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

Smile

Regards,

WilliamD
James Goodwin
James Goodwin
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1667 Visits: 1107
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
malathi.nicegirl
malathi.nicegirl
SSC Rookie
SSC Rookie (40 reputation)SSC Rookie (40 reputation)SSC Rookie (40 reputation)SSC Rookie (40 reputation)SSC Rookie (40 reputation)SSC Rookie (40 reputation)SSC Rookie (40 reputation)SSC Rookie (40 reputation)

Group: General Forum Members
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?? Smile
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search