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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:46:57+00:00 2026-06-06T06:46:57+00:00

I am looking to iterate through a USERS table, and for each user selected

  • 0

I am looking to iterate through a USERS table, and for each user selected based on my where clauses, perform a bunch of mysql queries within the LOOP, including temp table creates, using prepare statements, etc

What is the best way in terms of performance should this be done. Using while, for each, for, repeat ?

eg.(Pseudo code)

foreach user_name in (select user_name from users where user_type = 'SP' and active = 'Y')
do
    set @l_query1 = concat("create temp_table_t1 select * from ...")
    PREPARE ..
    EXECUTE ...

    set @l_query2 = ... 
    ....
    .... etc .. 
done

Ok, i have a table users, where pK = user_name.

So,this query will be fast to execute,
I just need to LOOP through this resultSet, and execute the remaining of the mySQL queries within the LOOP.
How can i LOOP through the resultSet of a simple select ?

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-06-06T06:46:58+00:00Added an answer on June 6, 2026 at 6:46 am

    There’s no difference in performance between while, for-each, repeat, etc.

    If you’re looking for performance gains, consider where you might reduce the number of queries the code executes on the database. For example, it would be a huge help to run a query once for all users, rather than running it once each for every user.

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

Sidebar

Related Questions

I have HTML table. I'm looping through table and iterate over each row whose
I'm looking for some code (C# or VB.NET preferred) to iterate through all folders
I'm looking for the best way to iterate through a folder and put all
So I'm trying to iterate through a list of files that are within a
after looking through a lot of similar questions on SO, I still can't iterate
Normally when you iterate through a mysql result you do something like this: while
I have a List<List<int>> in F#. I need to iterate through it looking for
I'm just looking for a nicer and more efficient way to iterate through a
Possible Duplicate: iterate through pairs of items in python list I have a list
I want to create a method that would iterate through a keyed collection. I

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.