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

  • Home
  • SEARCH
  • 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 324649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:08:37+00:00 2026-05-12T09:08:37+00:00

I have the following two tables: USER FID UID VALUE 4 3 John 3

  • 0

I have the following two tables:

USER
FID  UID     VALUE
4    3       John
3    3    Doe
4    4       Jack
3    4       Russel

Should be fairly clear that FID 3 = Surname, and FID 4 = Name.

DATEDATA
UID  DATE  
3    1234
4    4321

I want to join these two tables, so that I end up with something like this:

UID  DATE  NAME   SURNAME
3    1234  John   Doe
4    4321  Jack   Russel

or… alternatively…

UID  DATE  FULLNAME
3    1234  John Doe
4    4321  Jack Russel

Any SQL gurus out there?

This is what I have so far:

SELECT UID, DATE, VALUE 
    from DATEDATA as D 
    left join USER as U 
    on U.uid = D.uid where fid = 3 OR fid = 4

But that gives me this:

UID  DATE  VALUE
3    1234  Doe
3    1234  John
4    4321  Russel
4    4321  Jack

Anyone?

  • 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-12T09:08:37+00:00Added an answer on May 12, 2026 at 9:08 am
    SELECT D.UID, DATE, U.VALUE + ' ' + U2.Value as fullName
    from DATEDATA as D 
    left join USER as U on U.uid = D.uid and U.fid = 3
    left join USER as U2 on U2.uid = D.uid and U2.fid = 4
    

    Though this could give you a NULL name whenever either first or last is NULL. You may want to use an ISNULL to make either name an empty string in that case if you can accept cases where the user would only have one name or the other in your system.

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

Sidebar

Related Questions

I've got the following problem: I have two tables: (simplified) +--------+ +-----------+ | User
I have the following two tables: auth_user id username is_active (boolean) ... useprofile_userprofile id
I have the following two tables, affiliates and referrers. affiliates Table id loginid 3
I have the following two tables: Customer { int Id int Name } Bills
I have the following two tables: Table1 ---------- ID Name 1 A 2 B
1I have the following two tables (sample data) and need to be able to
Say for example, I have the following two tables: TableA { _id } TableB
I am using VB.NET with LINQ to MS SQL. I have two following tables.
I have two tables invoices and pending_payments both of which have the following rows
I have two tables in a SQLite DB, and both have the following fields:

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.