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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:45:50+00:00 2026-05-14T05:45:50+00:00

I have a set of sql – queries: List<String> queries = … queries[0] =

  • 0

I have a set of sql – queries:

List<String> queries = ...
queries[0] = "select id from person where ...";
...
queries[8756] = "select id from person where ...";

Each query selects rows from the same table ‘person’. The only difference is the where-clause.
Table ‘person’ looks like this:

   id | name | ... many other columns

How can i determine which queries will contain a certain person in it’s result set?

For example:

List<Integer> matchingQueries = magicMethod(queries, [23,45]); 

The list obtained by ‘magicMethod’ filters all sql queries present in the list ‘queries’ (defined above) and returns only those that contain either the person with id 23 OR a person with id 45.

Why i need it:
I am dealing with an application that contains products and categories where the categories are sql queries that define which products belong to them (queries stored in a table also).
Now i have a requirement where an admin has to see all categories an item belongs to immediately after the item was created. Btw, over 8.000 categories defined (so far, more to come).

language and db: java && postgreSQL

Thanks,

  • 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-14T05:45:51+00:00Added an answer on May 14, 2026 at 5:45 am

    I can think of 2 ways. First way is to create a value object Query which contains two properties: a Long id query ID and a List<Person> results. Another way is to include the query ID in the results. E.g.

    queries[0] = "SELECT id, name, etc, 0 AS query FROM person WHERE ...";
    // ...
    queries[8756] = "SELECT id, name, etc, 8756 AS query FROM person WHERE ...";
    

    or

    queries[0] = "SELECT id, name, etc, %d AS query FROM person WHERE ...";
    // ...
    queries[8756] = "SELECT id, name, etc, %d AS query FROM person WHERE ...";
    
    for (int i = 0; i < queries.length; i++) {
        String sql = String.format(queries[i], i);
        // ...
    }
    

    so that you can re-obtain it by

    int queryId = resultSet.getInt("query");
    

    That said, this is all with all a bit a smell (DRY). I’d recommend to rethink the whole approach. Feel free to ask it as a new question, “I have functional requirement XYZ, I have approached it as follows. Is it right?”.

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer While it is possible to develop free standing applications that… May 14, 2026 at 9:46 pm
  • Editorial Team
    Editorial Team added an answer StandardAnalyzer should work fine for all above queries. Your first… May 14, 2026 at 9:46 pm
  • Editorial Team
    Editorial Team added an answer I'm writing an app that has a foreground service, content… May 14, 2026 at 9:46 pm

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.