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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:32:51+00:00 2026-05-12T00:32:51+00:00

Say I have a query that fetches [type][show_name]. For all [type]==5 records, I need

  • 0

Say I have a query that fetches [type][show_name].
For all [type]==5 records, I need to join them with another table.

What would be the best approach for that:

  1. Join for all records between the two tables (looks bad).
  2. Run the query and then run again on the result set, fetch all the IDs and do a IN query on the table I need to join with.
  3. Fetch the missing data only after what I have is presented (using the same IN query), maybe with an AJAX approach.
  4. Something I haven’t thought of.

Important thing is, I want the user to see at least some of the data as fast as possible, but I also want the code to be straight forward, without too much spaghetti.

  • 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-12T00:32:51+00:00Added an answer on May 12, 2026 at 12:32 am

    You could do a left join and put the type=5 clause inside the join condition. This will return you null in the other table if the type isn’t 5.

    select
        a.type,
        a.show_name,
        b.whatever
    from
        tableA a
        left outer join tableB b on
            a.id = b.id
            and a.type = 5
    

    This works because it only joins the records with type=5. If you were to put a.type=5 inside the where clause, it would limit your result set to those where type=5.

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

Sidebar

Related Questions

Let's say I have a query that is run all 15min. I just need
I have the query below that fetches 500 records according to certain criteria. The
I can't seem to get the join / query that I need! Lets say
Say I have a query that returns 10,000 records. When the first record has
Here is a silly question. Lets say I have a query that produces for
Lets say that we have a query like this one: SELECT *, (CUSTOM_EXPRESSION) as
lets say i have a background worker in a class that perform db query
Let's say that I have an error in a php/mysql query : $query =
Say I have 3 queries. Query 1 returns a piece of information that Query
Let's say I have a query result that looks as follows: ID NAME Phone

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.