SQL – Joining to a Single Row

Comments 0

Share to social media

If you have a one-to-many relationship, and you are performing a join on the tables but you only want one record from the “many” portion of the relationship, then this is a very helpful link:

http://stackoverflow.com/questions/2281551/tsql-left-join-and-only-last-row-from-right

The outer apply appears to be very useful for joining a single row in one table to a very specific single row in another table.  Not sure about efficiency, but it gets the job done.

Load comments

About the author

Damon Armstrong

See Profile

Damon Armstrong is a consultant with SystemwarePS in Dallas, Texas. He is also a blogger and author of Pro ASP.NET 2.0 Website Programming and SharePoint 2013 Essentials for Developers. He specializes in the Microsoft stack with a focus on web technologies like MVC, ASP.NET, JavaScript, and SharePoint. When not staying up all night coding, he can be found watching a bunch of kids, studying Biblical topics, playing golf, or recovering from staying up all night coding.