Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
how to setup mysql query that requires looping

This is a little bit of a weird question, however, I have this function:

async function getNumOfSessionForTrainerClientList(req, res, rows, allowedToAddMoreClients, alertMessage) {

  var getNumOfSessionForTrainerClientList = "select * from SCHEDULE WHERE USERNAME = ? AND ASSIGNED_TRAINER = ?"
  mysqlconn.connect(async function(err) {
    if (err) {
      console.error('Database connection failed: ' + err.stack);
      return;
    }
    mysqlconn.query(getNumOfSessionForTrainerClientList, [rows.USERNAME, req.session.username], async function(err, sessionData) {
      if (err) {
        console.log(err);
      } else {
        //go to checkIfUserPaid
        // console.log("Lenght or rows: " + sessionData.length);
        console.log(sessionData.length)
        console.log(sessionData)
        sessionData2.push(sessionData)
        res.render('trainerclientlist.ejs', {
          data: rows,
          trainerFirstName: req.session.firstname,
          trainerLastName: req.session.lastname,
          allowedToAddMoreClients: allowedToAddMoreClients,
          profilePhoto: req.session.profilePhoto,
          alertMessage: req.session.selectedalertmessage,
          sessionData: sessionData
        })
      }
    })
  })
}

what this does it just a query that queries my schedule table, however, I need to get the results from this table for what could be up to 25 people. So i don't want to go and loop the query based on the number of rows i have from rows, so I'm not sure what to do. any ideas?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!