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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:06:07+00:00 2026-05-23T13:06:07+00:00

I need a help with a small query. Table A:- status and the contents

  • 0

I need a help with a small query.

Table A:- status and the contents of it are below.

 status_id      status_descrip 
        1          held 
        2          release 
        3          WIP

Table B:- Entry is another table which has some 30 fields. Out of which 2 fields are referring to Table A-> status table. For simplicity i am skipping other fields and jotting down only the fields related with status.

 entry_id        design_status         stress_status
     1                 3                   1
     2                 1                   2
     3                 NULL                2
     4                 3                   3
     5                 NULL                1
     6                 NULL               NULL      
     7                 NULL                2   

I can’t change the structure of Entry to split into 2 tables one as design_status and other as stress_status.

Now i want the entries from entry table replace the status with their descriptions. so the output will be

   entry_id        design_status_descrip         stress_status_descrip
      1                   WIP                          held
      2                   held                         release
      3                   NULL                         release
      4                   WIP                          WIP.
      5                   NULL                         held
      6                   NULL                         NULL
      7                   NULL                         release

Thanks in advance!

EDIT:-

Question is edited with Entries.

Thankyou for all your responses!

and the query finally working for me is,

SELECT     b.entry_id,     design_status_descrip = d.status_descrip,   
  stress_status_descrip = s.status_descrip FROM     entry AS b   
  LEFT OUTER JOIN status AS d     ON b.design_status = d.status_id   
  LEFT OUTER JOIN  status AS s     ON b.stress_status = s.status_id

do let me know, if i can improve this query.

  • 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-23T13:06:07+00:00Added an answer on May 23, 2026 at 1:06 pm

    The simplest way would be to join against the status table twice. I’ve used INNER JOIN assuming that the design_status and stress_status columns in your schema have proper constraints. Edited for changed requirements.

    DECLARE @status TABLE
    (
        status_id INT PRIMARY KEY,
        status_descrip VARCHAR(32) NOT NULL UNIQUE
    );
    
    INSERT @status SELECT 1,'held' UNION SELECT 2,'release' UNION SELECT 3,'WIP';
    
    DECLARE @b TABLE
    (
        entry_id INT PRIMARY KEY,
        design_status INT,
        stress_status INT
    );
    
    INSERT @b SELECT 1,3,1
    UNION SELECT 2,1,2
    UNION SELECT 3,NULL,2
    UNION SELECT 4,3,3
    UNION SELECT 5,NULL,1
    UNION SELECT 6,NULL,NULL
    UNION SELECT 7,NULL,2;
    
    SELECT
        b.entry_id,
        design_status_descrip = d.status_descrip,
        stress_status_descrip = s.status_descrip
    FROM
        @b AS b
        LEFT OUTER JOIN @status AS d
        ON b.design_status = d.status_id
        LEFT OUTER JOIN @status AS s
        ON b.stress_status = s.status_id;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am newbie to db programming and need help with optimizing this query: Given
I need a small help. In my project there is a tab bar. On
Need some help with a small problem. I'm not too hot on the maths
I need a small help in List view. I am generating a list View,
I am working on a small project and need your help. Here are the
I need some help with my xpath query. I can get this code to
I need to build a search query on Customers table join with orders table
I need small help with jquery. EDIT: echo <li> ; echo $navi_menu->navi_name; echo <ul>;
hello guys i need small help in understanding file system of android Now in
Sorting is giving me a hard time. I need help with an small example,

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.