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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:06:31+00:00 2026-05-28T17:06:31+00:00

I have a query and a loop written that lists all the rows from

  • 0

I have a query and a loop written that lists all the rows from a mysql table (“records”) formatted in a HTML table.

One of the fields is “subject_id” which is an integer. I also have a table named “subjects” which corresponds to the same “subject_id” in the records table. Only two fields are in the “subjects” table, is an auto-index ID integer and a varchar(1024) for the subject title.

The value that returns from the “records” table is an integer. I want to perform a lookup on the integer from the “records” table for each row to output the text equivalent from the “subject_id” field.

My first notion, the kindergarten way, would be to throw in another query within the loop, effectively increasing my number of queries from 300 to 600 to load the page (no pagination is needed).

What would be a better way of this “sub query” aside from adding 300 more queries?

Edit:
I’m pulling the data from the table using a while loop and echoing my variable $r_subject (from: $r_subject = mysql_result($result,$a,”subject”);). The value returned from the initial records table is INT. I want to take the $r_subject and then check it against the SUBJECTS table to get the string name associated with that INT id.

  • 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-28T17:06:31+00:00Added an answer on May 28, 2026 at 5:06 pm

    It’s hard to know exactly what you need without seeing code, but from what I gather, you have 2 tables, one has the ID, the other has the text, so you would want to use a join.

    The second thing is, you’ll want to look at whether or not you really need 300 queries in the first place. That’s a lot of queries to run and you should only need to run that many queries when you’re running a bulk insert/update or something of that nature; other than that, you most likely could reduce that number substantially.

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

Sidebar

Related Questions

I have an AJAX script that receives a string from a mySQL query returned
I am using in C# MYsql .I have query that works if I run
I have a query that I'm executing from a .NET application to a SQL
I have written a loop in wordpress that loops through the post titles and
I have a query that's running slow (in a loop of about 100 it
I have this query: $result = mysql_query(SELECT id,pic0,bio,url FROM .$table. WHERE id LIKE '%custom%'
I have a linq to objects query in a recursive loop and afraid when
I've noticed that a few Wordpress blogs have query statistics present in their footer
I have a query where I wish to retrieve the oldest X records. At
I have a query that is dynamically built after looking up a field list

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.