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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:15:33+00:00 2026-05-28T08:15:33+00:00

Hopefully this will be an easy question! I have two tables, a ‘client(s)’ table

  • 0

Hopefully this will be an easy question!

I have two tables, a ‘client(s)’ table and an individual ‘names’ table. The basis is that a client can have one or two(max) names. I structured them like this so that each ‘name’ can have a different title. The tables are:

clients
+------------+-------------+------------+
| clientID   | nameID1     | nameID2    |
+------------+-------------+------------+
|          1 | 1           | 2          |
|          2 | 3           |            |
|          3 | 4           |            |
+------------+-------------+------------+


names 
+------------+-------------+------------+------------+
| nameID     | surname     | initials   | titleID    |
+------------+-------------+------------+------------+
|          1 | Banks       | P          | 1          |
|          2 | Smith       | W          | 2          |
|          3 | Wilson      | BT         | 2          |
|          4 | Jefferson   | JP         | 3          |
+------------+-------------+------------+------------+

Where titleID is retrieved from…

titles 
    +------------+-------------+
    | titleID    | titleName   |
    +------------+-------------+
    |          1 | Mr          |
    |          2 | Mrs         |
    |          3 | Miss        |
    +------------+-------------+

So for instance clientID = 1 is Mr P Banks ‘&’ Mrs W Smith

The problem is I’m not familiar with querying to get that answer above.

I cannot try:

SELECT
clientID, names.surname, names.initials, titleName
FROM clients, names, titles
WHERE titleID = titleID AND
NameID1 = nameID AND
NameID2 = nameID

How do I correctly join the tables in a query to find, e.g.,
clientID 1 = Mr P Banks '&' Mrs W Smith

  • 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-28T08:15:34+00:00Added an answer on May 28, 2026 at 8:15 am

    You need to join to the Names (and Titles) table twice, once for nameID1, and once for nameID2. I’ve assumed that the client must have at least one name hence nameID1 is INNER JOIN, and since namedID2 is optional (nullable) it is LEFT OUTER JOIN.

    SELECT c.clientID, n1.surname, n1.initials, t1.titleName, n2.surname, n2.initials, t2.titleName
    FROM clients c
    INNER JOIN names n1 ON nameID1 = n1.nameID
    INNER JOIN titles t1 ON n1.titleID = t1.titleID
    LEFT OUTER JOIN names n2 ON nameID2 = n2.nameID
    INNER JOIN titles t2 ON n2.titleID = t2.titleID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This will hopefully be an easy one. I have an F# project (latest F#
hopefully this will be an easy answer for some of you CSS veterans out
Hopefully, this will be an easy answer for someone with Javascript time behind them...
Hopefully this will not spark a religious war... We have a web based app
I've tried to simplify for the purposes of asking this question. Hopefully, this will
( Late edit: This question will hopefully be obsolete when Java 7 comes, because
Hopefully this will be an easy one to answer. I created a class in
Hopefully this will be an easy one to answer. I am working on a
Hopefully this will be clear enough. I have a 2d map made of tiles,
Hopefully an easy question, but I'd quite like a technical answer to this! What's

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.