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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:24:18+00:00 2026-06-18T01:24:18+00:00

Could you please help me to resolve this issue? I have 2 tables as

  • 0

Could you please help me to resolve this issue?

I have 2 tables as below:

attributes

| id | name         |
|----+--------------|
| 1  | first_name   |
| 2  | last_name    |
| 3  | email        |

attribute_values

| uid   | attr_id   | value     |
|-------+-----------|-----------|
| 1     | 1         | Hello     |
| 1     | 2         | world     |
|-------+-----------|-----------|
| 2     | 1         | A         |   
| 2     | 2         | B         |
| 2     | 3         | a@xzy.com |

I want to write a query to select attributes of a user even if attribute is not exist in table attribute_values. Then, I would like to get result with null value.

For example for selecting user id 1

| name          | value     |
|---------------|-----------|
| first_name    | Hello     |
| last_name     | world     |
| email         | NULL      |

user id 2

| name          | value     |
|---------------|-----------|
| first_name    | A         |
| last_name     | B         |
| email         | a@xzy.com |

user id 3 (not exist in attribute_values)

| name          | value     |
|---------------|-----------|
| first_name    | NULL      |
| last_name     | NULL      |
| email         | NULL      |

Is there best way with one query to get result as 3 above examples?

Thanks.

  • 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-18T01:24:20+00:00Added an answer on June 18, 2026 at 1:24 am
    SELECT  a.*, b.value
    FROM    attributes a
            LEFT JOIN attribute_values b
                ON a.ID = b.attr_id AND b.uid = 1
    
    • SQLFiddle Demo
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could anyone please help me convert this code to vb.net, I have tried it
Am trying to resolve the below query. Please could you help? BANKTABLE BT AccountNumber
Could you please help me converting this c++ code into python: I am trying
Could someone please help me to convert this String into a Map ... String
Could somebody please help me get Clang up and running? (I don't have 3.2)
Could someone please help explain why I can't get this to work? I properly
I hope some can help me on this issue. The purpose of this email
I'm trying to get this resolve for days but no luck yet. Please help
[Update:] i know the problem... but need help to resolve this. The issue is
I spent couple of hours to resolve this weird issue. I have date formate

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.