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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:05:42+00:00 2026-05-21T18:05:42+00:00

I have a table with about 150 websites listed in it with the columns

  • 0

I have a table with about 150 websites listed in it with the columns “site_name”, “visible_name” (basically a formatted name), and “description.” For a given page on my site, I want to pull site_name and visible_name for every site in the table, and I want to pull all three columns for the selected site, which comes from the $_GET array (a URL parameter).

Right now I’m using 2 queries to do this, one that says “Get site_name and visible_name for all sites” and another that says “Get all 3 fields for one specific site.” I’m guess a better way to do it is:

SELECT * FROM site_list;

thus reducing to 1 query, and then doing the rest post-query, which brings up 2 questions:

  1. The “description” field for each site is about 200-300 characters. Is it bad from a performance standpoint to pull this for all 150 sites if I’m only using it for 1 site?
  2. How do I reference the specific row from the MySQL result set for the site specificed in the URL? For example, if the URL is “mysite.com/results?site_name=foo” how do I do the post-query equivalent of SELECT * FROM site_list where site_name=foo; ?

I don’t know how to get the data for “site_name=foo” without looping through the entire result array and checking to see if site_name matches the URL parameter. Isn’t there a more efficient way to do it?

Thanks,

Chris

PS: I noticed a similar question on stackoverflow and read through all the answers but it didn’t help in my situation, which is why I’m posting this.

Thanks,

Chris

  • 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-21T18:05:43+00:00Added an answer on May 21, 2026 at 6:05 pm

    I believe what you do now, keeping sperated queries for getting a list of sites with just titles and one detailed view with description for a single given site, is good. You don’t pull any unneeded data and both queries being very simple are fast.

    It is possible to combine both your queries into one, using left join, something maybe like:

    SELECT s1.site_name, s1.visible_name, s2.description
    FROM site_list s1
    LEFT JOIN
      ( SELECT site_name, description
      FROM site_list
      WHERE site_name = 'this site should go with description' ) s2
    ON s2.site_name = s1.site_name
    

    resulting in all sites without matching name having NULL as description, you could even sort it using

    ORDER BY description DESC, site_name
    

    to get the site with description as first fetched row, thus eliminating need to iterate through results to find it, but mysql would have to do a lot more work to give you this result, negating any possible gain you could hope for. So basically stick to what you have now, its good.

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

Sidebar

Related Questions

I have a simple query for update table (30 columns and about 150 000
I have a table with about 150 rows in it. These are the data
I have a table of about a million rows and I need to update
I have a fairly simple sync problem. I have a table with about 10
I have a table that has about 1/2 million records in it. Each month
I have a table that holds information about cities in a game, you can
Say I have at database table containing information about a news article in each
I have been reading about the differences between Table Variables and Temp Tables and
I have a basic property bag table that stores attributes about my primary table
I have a table of over 150,000 rows of which most would be updated

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.