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

The Archive Base Latest Questions

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

I have the following db table (People): +——–+——–+——–+——–+ | Name |Building| Nr | Time

  • 0

I have the following db table (People):

+--------+--------+--------+--------+
|  Name  |Building|   Nr   |  Time  |
+--------+--------+--------+--------+
| Tim    | House  |   30   |  10:10 |
| Jill   | House  |   31   |  10:20 |
| Tim    | Flat   |   31   |  10:30 |
| NULL   | Tower  |  NULL  |  NULL  |
| Jack   | Hut    |   32   |  10:50 |
| Jane   | Cabin  |   35   |  10:60 |
| Susan  | Cabin  |   35   |  11:70 |
+--------+--------+--------+--------+ 

Now I want to show all Buildings (and the data that comes with it) that Tim owns. I did that like this:

SELECT * FROM `People` WHERE Name="Tim"

Result:

+--------+--------+--------+--------+
|  Name  |Building|   Nr   |  Time  |
+--------+--------+--------+--------+
| Tim    | House  |   30   |  10:10 |
| Tim    | Flat   |   31   |  10:30 |

So far so good. The thing is, there are more buildings (Tower, Hut and Cabin). I want to show these too but leave the data (accept the building type) blank.

This result is that I need:

+--------+--------+--------+--------+
|  Name  |Building|   Nr   |  Time  |
+--------+--------+--------+--------+
| Tim    | House  |   30   |  10:10 |
| Tim    | Flat   |   31   |  10:30 |
| NULL   | Tower  |  NULL  |  NULL  |
| NULL   | Hut    |  NULL  |  NULL  |
| NULL   | Cabin  |  NULL  |  NULL  |
+--------+--------+--------+--------+

Since Tower was already NULL I can easily extract that one using:

SELECT * FROM `People` WHERE Name="Tim" OR Name is NULL

Result:

+--------+--------+--------+--------+
|  Name  |Building|   Nr   |  Time  |
+--------+--------+--------+--------+
| Tim    | House  |   30   |  10:10 |
| Tim    | Flat   |   31   |  10:30 |
| NULL   | Tower  |  NULL  |  NULL  |
+--------+--------+--------+--------+

Problem is, I still miss the Hut and Cabin. Can this even be done with a query? Also tried some options like GROUP BY etc but this gave mixed data in return. Also searched using Google but had no luck.

Hope anyone can help me out!

ps. as a workaround I can add in the db:

 | NULL   | Hut    |  NULL  |  NULL  |
 | NULL   | Cabin  |  NULL  |  NULL  |

But that will be a immense job to contain this table when you add more buildings

  • 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-28T03:33:10+00:00Added an answer on May 28, 2026 at 3:33 am

    Something like

    select * from people where Name = 'Tim' 
    union 
    select 'NULL', Building, NULL, NULL from   people where Name != 'Tim';
    

    Can do what you want ?

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

Sidebar

Related Questions

I have the following database table (People): +--------+--------+--------+ | Name | Age | Time
I have a table that returns the following TABLE People Name id Paco 18
I have a table named People in the following format: Date | Name .
Lets say I have the following (2) tables: [People Table] ID   Name 1
I have the following table of people and their birthdays: name birthday ---------------------- yannis
I have the following table structure CREATE TABLE `table` ( `id` int(11) NOT NULL
I have the following table, let's call it People : id | customer |
I have the following database table with information about people, diseases, and drugs: PERSON_T
I have the following database table with information about people, diseases, and drugs: PERSON_T
If I have three columns in my MySQL table people , say id, name,

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.