开发者

What is wrong with this sample query? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.
SELECT table0.person_name, table5.an开发者_开发百科imal_name 
FROM table1 
JOIN table0 ON table1.person_id = table0.person_id
JOIN table5 ON table1.animal_id = table5.animal_id
WHERE table1.aa = input1 
  AND table1.bb = input2 
  AND table1.cc = input3 
  AND table1.dd = input4

an answerer said

If you ever even get close, you're doing it wrong :) – Jamiec 1 hour ago

whats wrong with it?

Join = inner join anything else?


The If you ever even get close, you're doing it wrong :) comment was in direct answer to the question: What is the maximum number of inner joins can a SQL query have?.

Indeed there is a limit to this number of joins, with all (most) DBMSes, including SQL Server, but this is not a practical limit, i.e. if you approaching it, your database / query structure probably needs to be revised.
Edit: It appears that with SQL2008 this limit has been removed (or rather "pushed" to "Limited only by available resources"). In SQL2000, the limit was 256, cf "Tables per SELECT statement"(which I think is one of the relevant limiting factors) in the following Microsoft documentation pages

  • MSSQL Server 2000
  • MSSQL Server 2008

I didn't find -nor look for in earnest- the SQL 2005 documentation. Also note that the SQL 2000 limit of 256 can likely be artificially boosted by introducing views (would one wish to go beyond a readily monster-ish 250+ tables query ;-) )

The query shown, in this question is quite proper syntactically and semantically, and will likely be efficient and provide the desired results; this of course depends on the specific intent and the particular indexes available (if the tables are "big").

[Stackoverflow] Point of order: typically you should try and address this kind of follow-up questions within the very original posting (unless the new question effectively discusses other concepts or issues, rather independent from the original question).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜