views:

80

answers:

1
SELECT table0.person_name, table5.animal_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?

A: 

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

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).

mjv