troubleshooting Question

Basic SQL Query Select Question FK tables

Avatar of sbornstein2
sbornstein2 asked on
Microsoft SQL Server
5 Comments1 Solution53 ViewsLast Modified:
Hello all,

Okay this is a basic question but want the best practice.   If I have a FK ID field in my main query FROM table that joins to that PK table.    I know it does not matter but best practice the ID field should that reference the main FROM table or the joined PF table.   For example,

IV.InvoiceGroupID,   --should this use the main table InvoiceGroupID or the IG table best practice
FROM Invoice IV
JOIN InvoiceGroup IG ON IV. InvoiceGroupID = IG.InvoiceGroupID

Also one other thing is the JOIN which table should always be the first in the ON statement?   Sometimes I find myself mixing them.

Again all best practice I am looking for.

Thanks all
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros