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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:15:29+00:00 2026-06-02T09:15:29+00:00

Using an MS Access database with the following design: Tables Equipment, Employees, CreditCard Fields

  • 0

Using an MS Access database with the following design:

Tables
Equipment, Employees, CreditCard

Fields
Equipment: ID, PrimaryEmployee, SecondaryEmployee
Employees: ID, CreditCard
CreditCard: ID, Number, Pin

So, a piece of equipment can have two different employees assigned to it. Each employee can have a CreditCard assigned to them, or not at all.

Based on the ID of a piece of Equipment:

  • If the piece of equipment has a SecondaryEmployeeID set, and that
    corresponding Employee has a CreditCard set, then return the value of
    that CreditCard.
  • Else If the piece of equipment has a PrimaryEmployeeID set, and that
    corresponding Employee has a CreditCard set, then return the value of
    that CreditCard.

I also have to pull the employee’s name from the Employees table in the same query, and thus, I was using a LEFT JOIN before, which seemed to make it impossible to do this in my knowledge.

EDITED

My current query attempt:

SELECT
    Equipment.ID,
    Equipment.PrimaryEmployee,
    Equipment.SecondaryEmployee,
    Employees.CreditCard,
    CreditCard.Pin
FROM
    (Equipment
        LEFT JOIN Employees ON Equipment.PrimaryEmployee = Employees.ID
    )
LEFT JOIN CreditCard ON Employees.CreditCard = CreditCard.ID
WHERE (((Equipment.EquipmentType)=1))

I removed some unrelated fields from the query to hopefully improve readability, and simplify the area I’m having troubles.

This is currently generating a result like:

ID    PrimaryEmployee    SecondaryEmployee    CreditCard    Pin
--------------------------------------------------------------------
1     John Doe           Jack Smith           1234567890    1234
2     Bubba Smith        Ryan Howard          2345678901    2345

The problem is that it only matches on the PrimaryEmployee. I need it to check the SecondaryEmployee first, and if that doesn’t have a match or credit card set, then match on the PrimaryEmployee. If neither match, then return Null or ‘-‘.

Let me know if additional information is still required.

  • 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-06-02T09:15:30+00:00Added an answer on June 2, 2026 at 9:15 am

    The easiest way to do this, without mucking up the SQL, is to create a second query that uses the results from your first query and pulls in the Employee column where your first result IS NULL.

    Once you’ve got your two queries, you’re just a stone’s throw from writing a third query that joins the results from both queries into a single output.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following problem in a Database using Access 2007 as front end
I am using following PHP code to connect to MS Access database: $odb_conn =
I have the following code for using an access database OleDbConnection con = new
I have the following problems with using ODBC driver with MS Access database my
AM querying an access database from vb6 using the following query INSERT INTO stock([i_name],[ref],[qty],[supplier_id])
AM querying an access database, selecting records from two tables, in vb6 using the
Using Access Database Table ID Time 001 100000 001 100005 001 103000 001 102500
Using Access 2003 Database Table1 Intime Outtime WorkTime OverTime 08:00:00 19:00:00 09:00:00 02:00:00 09:00:00
USING MS ACCESS 2003 How to check is null value in the access database?
I am using Microsoft Access database for storing data. In that, I stored date

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.