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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:21:10+00:00 2026-06-13T14:21:10+00:00

I have a query which lists 10 different items in a database. Within this

  • 0

I have a query which lists 10 different items in a database.

Within this query, i have a nested query which, for each of items 1-10 listed above, finds related subcategories in another table.

So ultimately, 11 queries occur. 1 to iterate through the major categories, and the other 10 to query and output for each of those categories.

Problem is, collectively, they output duplicated values.

Since it is done over 10 queries, i cant use DISTINCT, because even if the output is distinct within its own query, it is not distinct in the overall group.

So how can i make sure that i multiquery list like this is unique? Does js or php have a built in function that can do such?

  • 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-13T14:21:11+00:00Added an answer on June 13, 2026 at 2:21 pm

    Your code is not really scaleable. You’re already reaching large numbers of queries, imagine if you had 100 items…

    Instead, consider creating a subquery within the original query, since this would allow you to only run one query and the MySQL engine can do all the crunch work more easily (since it knows what you’re actually asking for).

    Make use of JOINs if possible, and pay close attention to indexes. I can’t really help more without seeing some code, but this should help because DISTINCT would suddenly be usable again.

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

Sidebar

Related Questions

Ok, so I have two lists of items which are of different types. var
I have a query which produces a list of orders like this: Invoice Description
I have one mysql query, which gets rows to designs list. In this list
I have this query which on executing in my sql command line client executes
I have this query which is a dependant query and taking much execution time
I have a simple list-type php page, which lists items according to a mysql
I have a database search query which search in the database for a word
I have two lists comprised of different complex-objects, and each one is from 2
I have a page which contains some search fields to query a database, and
I have a select query which returns a list of data and I need

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.