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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:05:32+00:00 2026-06-02T06:05:32+00:00

[SOLVED: thanks to bluefeet and Brian I got to build this working query (turned

  • 0

[SOLVED: thanks to bluefeet and Brian I got to build this working query (turned out I also needed a fourth table / view)]”

SELECT        A.SalesLineID, A.ArticleResultID, B.ID, C.ID, D.Value
FROM            VIEWA AS A 
                INNER JOIN TABLEB AS B ON A.ArticleResultID = B.ArticleResultID 
                AND B.Name = N'Collect' AND DAPR.Value = 1 
                INNER JOIN TABLEC AS C ON B.ArticleResultID = C.ID 
                AND C.Name='Assemble' 
                AND C.Value = 1 
                INNER JOIN TABLED AS D ON D.ArticleResultID = C.ParentId 
                AND D.Name = 'IndexY'
WHERE        (A.SalesID = @SalesID)

[UPDATE: I’ve made a mistake assuming IndexY/Color and ProdId where fields Table A is some kind of parameter / property table with only 5 columns ID – NAME – VALUE – ARTICLERESULTID – PRODID. IndexY is a value of the Name field..]

I’m having trouble building the right sql query to get this trick done:

I have the following 2 tables:

Table A 
ID Name         Value   ArticleResultID     ProdID    Color
1  Operation    Collect             110         10    BLACK
2  IndexY            10             110         10    - 
3  Operation    Collect             101         11    WHITE


Table B
ID  ParentID    Name        Value       
101 110     Assemble        1       
101 100     Assemble        0     

Steps:

Find record in A with Name = Operation and Value = Collect and ProdId = 11 AS ORG_A
Find record in B With B.ID = ORG_A.ArticleResultId AND B.NAME = 'Assemble'AND B.VALUE = 1 AS B
Find record in A With A.ArticleResultID = B.ParentID as NEW_A

In the above scenario thats ORG_A.ArticleResultID = 11 –> B.ParentID = 110 –> NEW_A.ARTICLERESULTID = 110 –> (IndexY – Value – 10)

Much appreciated if someone can tell me how to build this query..

Best regards,

Mike D

[OLD DESCRIPTION:]

I’m having trouble building the right sql query to get this trick done:

I have the following 2 tables:

Table A 
Name        Value   ArticleResultID      IndexY      Color  ProdID
Operation   Collect             110         10           -       0
Operation   Collect             101         _        Black     100  


Table B
ID  ParentID    Name        Value   Dx      Dy
101 110     Assemble        1       1000    500 
101 100     Assemble        0       400     300

I want to fetch all records from A where NAME equals ‘operation’, VALUE equals ‘Collect’ and PRODID = ‘100’ but I also want (here’s my problem) the IndexY value of the record in Table A with the PARENTID in Table B which joins on TABLE B.ID = A.ArticleResultID AND Name = ‘Assemble’ and VALUE = ‘1’

In the above scenario thats ParentID 110 which gives me the record in Table A with ArticleResultID 110 with IndexY (10).

Much appreciated if someone can tell me how to build this query..

Best regards,

Mike D

  • 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-02T06:05:35+00:00Added an answer on June 2, 2026 at 6:05 am

    Since your requirements are not the clearest. How about this:

    SELECT a1.*, a2.indexy as additionalIndexY
    FROM ta a1
    INNER JOIN tb b
        ON a1.articleresultid = b.id
    INNER JOIN ta a2
        ON b.parentid = a2.articleresultid
    WHERE a1.name = 'Operation'
        AND a1.prodid = 100
        AND b.name = 'Assemble'
        AND b.value = 1
    

    Here is a sqlfiddle with a working version

    If you just want the record with the 110 articleresultid, then:

    SELECT a2.*
    FROM ta a1
    INNER JOIN tb b
        ON a1.articleresultid = b.id
    INNER JOIN join ta a2
        ON b.parentid = a2.articleresultid
    WHERE a1.name = 'Operation'
        AND a1.prodid = 100
        AND b.name = 'Assemble'
        AND b.value = 1
    

    see the sqlfiddle for the second example

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

Sidebar

Related Questions

I understand the problem that OSGI solved thanks to this question.... What does OSGi
UPDATE: Solved. Thanks BusyMark! EDIT: This is revised based on the answer below from
This problem has been solved! Thanks a lot to Brad, Denis and junkie! You're
SOLVED: Thanks figured it out thanks to dominic hamon. It all boils down to
This question is now solved - I used the below: And, problem solved thanks
This problem has been solved thanks to your suggestions. See the bottom for details.
EDIT: SOLVED Thanks Brooks. Your question led me to keep digging into if the
SOLVED I misspelled the property department -> Department. Thanks for the answers and a
How to adjust the font for the following:(solved) fontSize 40 BOLD Italicized Thanks The
SOLVED: Crap... why is it always you figure something out right AFTER you finally

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.