Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7649317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:56:06+00:00 2026-05-31T10:56:06+00:00

I am using the AdvetureWorks database. Here is what I would like to do:

  • 0

I am using the AdvetureWorks database. Here is what I would like to do:
Give me the Last Name, First Name, company name and list me all the addresses for customer Virginia Miller, include address type, address, city and state.
You need to join 3 tables together and filter the results. You should only get 2 rows.
This is what I have so far…

Select
SalesLT.Customer.LastName,
SalesLT.Customer.FirstName,
SalesLT.Customer.CompanyName,
CustomerAddress.AddressType,
SalesLT.Address.AddressLine1,
SalesLT.Address.City,
SalesLT.Address.StateProvince

From SalesLT.Customer C, SalesLT.CustomerAddress CA, SalesLT.Address A


 join SalesLT.CustomerAddress

on SalesLT.Address.AddressID=SalesLT.CustomerAddress.AddressID


join SalesLT.Customer
on SalesLT.CustomerAddress.CustomerID=SalesLT.Customer.CustomerID

join SalesLT.Address
on SalesLT.CustomerAddress.AddressID=SalesLT.Address.AddressID

Where SalesLT.Customer.FirstName = 'Virginia'

Yeah I am new and not understanding joins very well. Any nudges in the correct direction are much appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T10:56:07+00:00Added an answer on May 31, 2026 at 10:56 am

    The point of a select statement is to get some data back in a specific way. This takes roughly the following form:

    select <columns>
    from <table/group of tables joined together/sub-query/tvf etc.>
    where <condition>
    

    1 – Now, the bit you’ve having the problem with seems to be the middle bit – we’ll do that first.

    You’ve got three tables which contain the data you want back in:

    SalesLT.Customer 
    SalesLT.CustomerAddress 
    SalesLT.Address
    

    And you want to join them together on the columns where the data relate to each other, in this case CustomerID. The inner join statement takes the following form (choosing inner join since all entries have a match in the other tables!):

    table1 inner join table2 on table1.columnname = table2.columnname
    

    and if we match up your example to this syntax, we get this:

    SalesLT.CustomerAddress INNER JOIN
                          SalesLT.Customer ON SalesLT.CustomerAddress.CustomerID = SalesLT.Customer.CustomerID INNER JOIN
                          SalesLT.Address ON SalesLT.CustomerAddress.AddressID = SalesLT.Address.AddressID
    

    Now the rest of the select statement sees this query as one big “collection” of data, almost as if it was one table – only each column is pre-fixed by the table name. Where you reference one elsewhere in the statement it isn’t always necessary to include the fully qualified name (as it can guess as long as there isn’t more than one column with the same name in the result set).

    2 – The filtering where clause you seem to have got the hang of, but you only seem to be filtering on first name, despite your initial requirements. Adding an additional one is easy:

    WHERE     (SalesLT.Customer.FirstName = 'Virginia') AND (SalesLT.Customer.LastName = N'Miller')
    

    3 – Finally there is the small matter of what you want back – this you already had correct.

    Combining what we’ve done together, you get the following query:

    SELECT     SalesLT.Customer.LastName, SalesLT.Customer.FirstName, SalesLT.Customer.CompanyName, SalesLT.CustomerAddress.AddressType, 
                          SalesLT.Address.AddressLine1, SalesLT.Address.City, SalesLT.Address.StateProvince
    FROM         SalesLT.CustomerAddress INNER JOIN
                          SalesLT.Customer ON SalesLT.CustomerAddress.CustomerID = SalesLT.Customer.CustomerID INNER JOIN
                          SalesLT.Address ON SalesLT.CustomerAddress.AddressID = SalesLT.Address.AddressID
    WHERE     (SalesLT.Customer.FirstName = 'Virginia') AND (SalesLT.Customer.LastName = N'Miller')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Rails 3.2.0 with haml and sass: I Would like to link an external
I'm using AdventureWorks sample database in a project. I can display the Customer's (being
Using AdventureWorks, for example, I want to get a list of all employees and
Using posh-git in powershell I am able to list all the items in the
I'll be using the AdventureWorks Database to illustrate my problem. I need to show
I'm using AdventureWorks as a database to get familiar with linq and asp.net interface
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
I'm using ADO.NET entity framework, and am using an AdventureWorks database attached to my
In database contains 50 databases (adventureworks,adventureworksDw,sampleDb.....) How we can I retrieve all the databases
using a binary search tree I need to add to a vector all int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.