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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:11:06+00:00 2026-05-13T15:11:06+00:00

Having this table (sorry, cant seem to get a decent layout here): PD Header

  • 0

Having this table (sorry, cant seem to get a decent layout here):

PD      Header         Text              Mask_Producer      Mask_Dep        Mask_Diam
----------------------------------------------------------------------------------------------
10      Producer       Aproducer         Aprod              *               *
10      Producer       Bproducer         Bprod              *               *
20      Diam           A                 Aprod              10              30
20      Diam           A                 Aprod              20              40
20      Diam           B                 Aprod              10              40
30      Dep            10                Aprod              10              *
30      Dep            20                Aprod              20              *
30      Dep            30                Aprod              30              *
20      Diam           A                 Bprod              20              40
30      Dep            10                Bprod              10              *

I am using the rows in the table as a filter/mask for selecting other rows.

So, user having already made a selection of rows with:

PD   Text
-------------
10   Aproducer
20   A

I would now like to find out what rows with PD=30 fits those previous choices:

PD=10, Text=Aproducer gives that Mask_Producer must be “Aprod”, (Mask_Dep and Mask_Diam are allowed to be anything by the stars)

PD=20, Text=A gives that Mask_Producer must be “Aprod” and Mask_Dep must be 10 or 20 and Mask_Diam must be 30 or 40 (or star)

I want the outcome to be rows 6 and 7 from the table above.

Then imagine this example with 2000rows and 20 Mask_xx fields….

I am thinking SQL like IN, LEFT JOIN, JOIN, and temporary tables to do this, but I think I may be complicating things too much….

  • 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-13T15:11:06+00:00Added an answer on May 13, 2026 at 3:11 pm

    This is the type of code I enede up using, it works, but as I add more criteria and fields I get more huge joins and in each join also more AND..OR…OR sequences, so any propositions for improvements are welcome! Especially I am consernde that this may be slow as data grovs? Analysis of what the sql sever has to do for my code is welcome too!

    Right now I have about 30 criteria/fields and some PHP code that generates the SQL query for me….

    But here is the smaller example for the principle:

    SELECT DISTINCT t30.*
    FROM
      (SELECT *
       FROM YourTable
       WHERE PD = 10
         AND Text = 'Aproducer') AS t10
    JOIN
      (SELECT *
       FROM YourTable
       WHERE PD = 20 AND Text = 'A') AS t20 ON 
         (t20.MaskProducer = t10.MaskProducer
                                    OR t20.MaskProducer = '*'
                                    OR t10.MaskProducer = '*')
         AND (t20.MaskDep = t10.MaskDep
                                    OR t20.MaskDep = '*'
                                    OR t10.MaskDep = '*')
         AND(t20.MaskDiam = t10.MaskDiam
                                    OR t20.MaskDiam = '*'
                                    OR t10.MaskDiam = '*')
    //more JOINS like the one above for each criteria
    // below the final join to get the result from
    JOIN
      (SELECT *
       FROM YourTable
       WHERE PD = 30) AS t30 ON 
           (t30.MaskProducer = t20.MaskProducer
                                 OR t30.MaskProducer = '*'
                                 OR t20.MaskProducer = '*')
            AND (t30.MaskDep = t20.MaskDep
                                 OR t30.MaskDep = '*'
                                 OR t20.MaskDep = '*')
            AND (t30.MaskDiam = t20.MaskDiam
                                 OR t30.MaskDiam = '*'
                                 OR t20.MaskDiam = '*');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 419k
  • Answers 419k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think it is because of the fill_parent attributes. The… May 15, 2026 at 10:17 am
  • Editorial Team
    Editorial Team added an answer It sounds like you need the bsearch_s() and qsort_s() functions… May 15, 2026 at 10:17 am
  • Editorial Team
    Editorial Team added an answer There's no specific type for double, Rails tries to be… May 15, 2026 at 10:17 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.