|
-
JOIN physical location vs ON location
Why does the physical order of the JOIN... vs the ON.... matter? This first sql statment executes just fine, but the second SQL statement gives the errors:
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "s.stno" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "g.student_number" could not be bound.
I am working with Microsoft SQL 2005
SELECT DISTINCT(s.sname)
FROM Student s
JOIN Grade_report g
ON s.stno = g.student_number
JOIN Section sec
ON g.section_id = sec.section_id
JOIN Course c
ON sec.course_num = c.course_number
AND c.course_name like 'ACC%'
SELECT DISTINCT(s.sname)
FROM Student s
JOIN Grade_report g
JOIN Section sec
JOIN Course c
ON s.stno = g.student_number
ON g.section_id = sec.section_id
ON sec.course_num = c.course_number
AND c.course_name like 'ACC%'
I am more familiar with the older WHERE clause style, and would likely most of the time use the format of the second select statement above, but it produces errors! So in general should the JOIN and the related ON clause stay physically close together. Or what tips or concepts should I have or know!
Thank-you!
Last edited by LuluDev; 02-12-2007 at 10:24 AM.
Similar Threads
-
Replies: 5
Last Post: 01-15-2006, 07:10 PM
-
Replies: 0
Last Post: 01-14-2006, 07:01 PM
-
Replies: 1
Last Post: 09-24-2002, 12:31 AM
-
By Larry Rebich in forum .NET
Replies: 0
Last Post: 08-03-2002, 03:19 PM
-
Replies: 0
Last Post: 12-10-2000, 11:15 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks