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 6214033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:48:19+00:00 2026-05-24T06:48:19+00:00

I need to do the exact same thing as shown here: INNER or LEFT

  • 0

I need to do the exact same thing as shown here: INNER or LEFT Joining Multiple Table Records Into A Single Row but have it work in an MS Access Query.

Below is the scenario:


Phone Table

+----------------+-------------+
| Field          | Type        |
+----------------+-------------+
| f_id           | int(15)     |
| f_client_id    | int(11)     |
| f_phone_type   | varchar(50) |
| f_phone_number | varchar(13) |
+----------------+-------------+

Clients Table

+-----------------------------+--------------+------+-----+
| Field                       | Type         | Null | Key |
+-----------------------------+--------------+------+-----+
| f_id                        | int(15)      | NO   | PRI |
| f_first_name                | varchar(13)  | YES  | MUL |
| f_mi                        | char(1)      | YES  |     |
| f_last_name                 | varchar(20)  | NO   | MUL |
+-----------------------------+--------------+------+-----+

With a standard LEFT or INNER join, I get something like this:

+------------+------------+--------------+
| name       | Phone Type | Phone Number |
+------------+------------+--------------+
| John Smith | Home       | 712-555-6987 |
| John Smith | Work       | 712-555-1236 |
+------------+------------+--------------+

I need a query that will give me the work and home numbers that belong to a given client:

+------------+----------------+--------------+
| Name       | Work Number    | Home Number  |
+------------+----------------+--------------+
| John Smith | 712-555-1236   | 712-555-6987 |
+------------+----------------+--------------+

The solution in SQL was

SELECT CONCAT(c.f_first_name, ' ', c.f_last_name) as Client_Name, 
       wp.f_phone_number as Work_Number,
       hp.f_phone_number as Home_Number

  FROM clients c
       LEFT OUTER JOIN phone hp
       ON hp.f_client_id = c.f_id
    AND
       hp.phone_type = 'home'
       LEFT OUTER JOIN phone wp
       ON wp.f_client_id = c.f_id
    AND
       wp.phone_type = 'work'

This however does not translate to MS Access, the Join fails. What’s the best way to accomplish this same thing through Access?

  • 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-24T06:48:21+00:00Added an answer on May 24, 2026 at 6:48 am

    There are two problems you haven’t discovered yet.

    1. there is no CONCAT() function in Access or its database engine
    2. your query attempts to use phone_type, but the actual field name is f_phone_type

    When joining more than two tables, Access’ database engine requires parentheses. It’s easiest to get that right by using the query designer to set up the joins. Also the query designer will substitute LEFT JOIN for LEFT OUTER JOIN; either way works for me in Access 2003.

    This one is easy to build in the query designer, but only returns rows for clients who have both home and work numbers. I used it as a starting point, then later adjusted the ON clauses similar to your original.

    SELECT
        c.f_first_name & " " & c.f_last_name AS [Name],
        wp.f_phone_number AS [Work Number],
        hp.f_phone_number AS [Home Number]
    FROM
        (Clients AS c
        LEFT JOIN Phones AS hp
        ON c.f_id = hp.f_client_id)
        LEFT JOIN Phones AS wp
        ON c.f_id = wp.f_client_id
    WHERE
        hp.f_phone_type='Home'
        AND wp.f_phone_type='Work';
    

    Moving those WHERE conditions into the ON expressions, as in your SQL Server example, will return all clients whether or not you have any phone numbers on file for them. However that approach will require parentheses around the ON expressions. And those JOINS can not be displayed in the query designer.

    SELECT
        c.f_first_name & " " & c.f_last_name AS [Name],
        wp.f_phone_number AS [Work Number],
        hp.f_phone_number AS [Home Number]
    FROM
        (Clients AS c
        LEFT JOIN Phones AS hp
        ON (c.f_id = hp.f_client_id AND hp.f_phone_type='Home'))
        LEFT JOIN Phones AS wp
        ON (c.f_id = wp.f_client_id AND wp.f_phone_type='Work');
    

    Update: For myself, I would prefer to do this with subqueries.

    SELECT
        c.f_first_name & " " & c.f_last_name AS [Name],
        wp.f_phone_number AS [Work Number],
        hp.f_phone_number AS [Home Number]
    FROM
        (Clients AS c
        LEFT JOIN [
            SELECT f_client_id, f_phone_number
            FROM Phones
            WHERE f_phone_type='Home'
        ]. AS hp
        ON c.f_id = hp.f_client_id)
        LEFT JOIN [
            SELECT f_client_id, f_phone_number
            FROM Phones
            WHERE f_phone_type='Work'
        ]. AS wp
        ON c.f_id = wp.f_client_id;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to support exact phrases (enclosed in quotes) in an otherwise space-separated list
I need to specify the exact length of a string to be printed from
I need to get the exact start and end dates (month, day and year)
I need a .NET regular expression that matches anything other than the exact full
In SQL Server (2005+) I need to index a column (exact matches only) that
In my iPhone application I need to use GPS (CoreLocation to be exact) to
In SharePoint (MOSS 2007) search, I need to match an exact number such as
I am currently writing a scientific article, where I need to be very exact
I'm currently trying to add gridlines to a canvas. I need an exact free
I need a custom dialog to appear on button press. Here is my code:

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.