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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:37:01+00:00 2026-05-25T10:37:01+00:00

I have 3 tables such as IndentHeader: IndentID StatusID ——– —— 1 5 2

  • 0

I have 3 tables such as

IndentHeader:

 IndentID        StatusID 
--------         ------   
    1             5      
    2             5

IndentDetail:

IndentID         ItemID           ItemStatusID
--------         ------           ------------
 1                22                 4
 1                23                 4
 2                11                 4
 2                12                 3
 2                13                 3

POIndent:

       POID             IndentID     ItemID      ItemStatusID
      --------           ------      ------      ------------
         1                1            22            4
         1                1            23            4
         1                2            11            4

I want to Update IndentHeader table StatusID = 4 when all the Items in the IndentDetail table (based on the IndentID) ItemstatusID becomes 4 otherwise I want to Update IndentHeader StatusID = 3. In the Condition I need to give POID. Based on the POID, the corresponding Indent is considered for both the IndentHeader and IndentDetail table. My desired Result should be like this:

IndentHeader:

 IndentID        StatusID 
--------         ------   
    1             4      
    2             3

How to achieve this? Please help me.

Hi all, this is my update command. But it update both the StatusID in IndentHeader as 4.

   UPDATE STR_IndentHeader
            SET StatusID = IID
            FROM
            (SELECT 
            STR_IndentDetail.IndentID, MIN(ItemStatusID) AS 'IID'
            FROM 
            STR_IndentDetail INNER JOIN PUR_POIndent PP
            ON PP.IndentID = STR_IndentDetail.IndentID
            AND PP.ItemID = STR_IndentDetail.ItemID
                        WHERE ItemStatusID = 4 AND PP.POID = 1
            GROUP BY STR_IndentDetail.IndentID) ID 
            WHERE ID.IndentID = STR_IndentHeader.IndentID 

I need all your valuable contributions. please help me…

  • 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-25T10:37:02+00:00Added an answer on May 25, 2026 at 10:37 am

    My [revised] solution use one ALL subquery to check ItemStatusID condition:

    DECLARE @MyPOID INT = 1;
    
    DECLARE @IndentHeader TABLE
    (
        IndentID INT PRIMARY KEY
        ,StatusID INT NOT NULL
    );
    INSERT  @IndentHeader 
    VALUES  (1,5);
    INSERT  @IndentHeader 
    VALUES  (2,5);
    INSERT  @IndentHeader 
    VALUES  (3,5);
    
    DECLARE @IndentDetail TABLE
    (
        IndentID INT NOT NULL
        ,ItemID INT NOT NULL
        ,ItemStatusID INT NOT NULL
        ,PRIMARY KEY(IndentID, ItemID)
    );
    INSERT  @IndentDetail
    VALUES  (1,22,4);
    INSERT  @IndentDetail
    VALUES  (1,23,4);
    INSERT  @IndentDetail
    VALUES  (2,11,4);
    INSERT  @IndentDetail
    VALUES  (2,12,3);
    INSERT  @IndentDetail
    VALUES  (2,13,3);
    INSERT  @IndentDetail
    VALUES  (3,22,3);
    
    DECLARE @POIndent TABLE
    (
        POID INT
        ,IndentID INT NOT NULL
        ,ItemID INT NOT NULL
        ,ItemStatusID INT NOT NULL
    );
    INSERT  @POIndent 
    VALUES  (1,1,22,4);
    INSERT  @POIndent 
    VALUES  (1,1,23,4);
    INSERT  @POIndent 
    VALUES  (1,2,11,4);
    INSERT  @POIndent 
    VALUES  (2,3,22,4);
    
    SELECT  *
    FROM    @IndentHeader h;
    SELECT  *
    FROM    @IndentDetail d;
    SELECT  *
    FROM    @POIndent po;
    
    UPDATE  @IndentHeader 
    SET     StatusID = CASE WHEN 4 = ALL(SELECT d.ItemStatusID FROM @IndentDetail d WHERE d.IndentID = h.IndentID) THEN 4 ELSE 3 END
    FROM    @IndentHeader h
    WHERE   h.IndentID IN (SELECT po.IndentID FROM @POIndent po WHERE po.POID = @MyPOID);
    
    SELECT  *
    FROM    @IndentHeader h;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables such as STR_IndentHeader and STR_IndentDetail. STR_IndentDetail: IndentID ItemID ItemStatusID --------
Let's say you have three tables named Item, Event, and Seat, constructed as such:
If i have tables such as: table_1: 1, 'Hello My Name is Hal', '2009:11:02
Such a task: we have 2 tables in our L2S Entity classes. It needs
Lets say I have two tables as such: People Id Name FirstDate LastDate --
I have two tables, one contains a lot of product information such as product_name
In Access 2007, I have two tables related such that the (surrogate) PK of
I have three tables such as user, job and job_applied. user table has uid
If I have two tables such as this: CREATE TABLE #table1 (id INT, name
i have such tables: movie: id, user, title thank: id, user, movie what i

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.