Results 1 to 3 of 3
  1. #1
    faca is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2018
    Posts
    52

    Combine 3 tables in query

    I want to combine 3 tables in query..


    Tables are:

    Customer (CustomerID, FirstName, LastName)
    Car (CarID, CustomerID, Make, Model)
    Service (ServiceID, CustomerID, Kilometers, DateOfService)



    If i put CarID in table Service it doesn't work (can't create new record) neither doesn't work if i enter CarID in query..

    How to solve this?

    I want this to be joined beacuse when ill create new service i'll pick customer and than i can choose related car (if customer has more than 1)

    Thanks

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 10 Access 2016
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    Maybe

    Code:
    SELECT Customer.CustomerID, Customer.FirstName, Customer.LastName, Car.CarID, Car.Make, Car.Model, Service.Kilometers, Service.DateOfService
    FROM (Customer INNER JOIN Car ON Customer.CustomerID = Car.CustomerID) INNER JOIN Service ON Car.CarID = Service.CarID;

  3. #3
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,938
    queries with multiple tables cannot be edited or have new records appended - although if you change the dataset type to inconsistent updates, you might be able to, but I wouldn't recommend it.

    instead you use a form, the rule being one table, one form. have your customer table on the main form and the other two tables in subforms.

    Your service table does not look right, think you need carid rather than customerid - you can get to customerid via the car table

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Compare and combine two tables with query.
    By xopherira in forum Queries
    Replies: 7
    Last Post: 08-04-2015, 05:09 PM
  2. Replies: 8
    Last Post: 07-11-2014, 12:36 PM
  3. Replies: 7
    Last Post: 06-19-2014, 12:00 PM
  4. Switch function query to combine tables
    By sandlucky in forum Queries
    Replies: 2
    Last Post: 03-29-2011, 09:46 PM
  5. combine three tables in a query
    By neuenglander in forum Queries
    Replies: 0
    Last Post: 08-21-2008, 04:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums