Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

263
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda