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

262
Views
Nodejs push data and get JSON from mysql

I have a search query running on nodejs modal as I put below. I am getting users from this query to my app as JSON data like this.

{id, username, name, sirname, birthdate, weight, height, photo}

{id, username, name, sirname, birthdate, weight, height, photo}

But I need to get users talents from an other table . So my JSON data must be like this.

{
id: 1 {talentone : 'good', talenttwo : 'bad', talentthree : 'good'}, 
username, name, sirname, birthdate, weight, height, photo}
{
id:2 {talentone : 'good', talenttwo : 'bad', talentthree : 'good'}, 
username, name, sirname, birthdate, weight, height, photo}
id:3 {talentone : 'good', talenttwo : 'bad', talentthree : 'good'}, 
username, name, sirname, birthdate, weight, height, photo}

My talents table: id - userId, talentName, talentRate

My user search query and nodejs code :

Searchtalent.getAll =(searchtalent, result) => {
  sql.query(`SELECT id, username, name, sirname, birthdate, weight, height, photo FROM users WHERE 
  user_type = 'sportsman'
  AND (birthdate BETWEEN '${searchtalent.birthdatefirst}' AND '${searchtalent.birthdatelast}')
  AND (weight BETWEEN ${searchtalent.wfirst} AND ${searchtalent.wsecond})
  AND (height BETWEEN ${searchtalent.hfirst} AND ${searchtalent.hsecond})
  AND lang LIKE '%${searchtalent.lang}%' 
  AND gender LIKE '%${searchtalent.gender}%' 
  AND username LIKE '%${searchtalent.username}%' 
  AND name LIKE '%${searchtalent.name}%' 
  AND sirname LIKE '%${searchtalent.sirname}%' 
  AND branch LIKE '%${searchtalent.branch}%' 
  AND branch_status LIKE '%${searchtalent.branch_status}%' 
  AND city LIKE '%${searchtalent.city}%' 
  AND foot LIKE '%${searchtalent.foot}%' 
  AND hand LIKE '%${searchtalent.hand}%' 
  AND first_position LIKE '%${searchtalent.first_position}%' 
  AND second_position LIKE '%${searchtalent.second_position}%' 
  AND nationality LIKE '%${searchtalent.nationality}%' 

LIMIT 50` ,(err, res) => {
    if (err) {
      console.log("error: ", err);
      result(err, null);
      return;
    }

    if (res.length) {
      console.log("found users: ", searchtalent);
      result(null, res);
      return;
    }

    // not found users with the id
    result({ kind: "not_found" }, null);
  });
};
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!