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

160
Vistas
how to do two sql queries in 1

I have this right now:

 var userLogin = "select * from users where username = ?";
ibmdb.open(ibmdbconn, function(err, conn) {
    if (err) return console.log(err);
    conn.query(userLogin, [inputUsername], function(err, rows) {
        if (err) {
            console.log(err);
        }

        //if the query returns results that are > 0
        if (rows.length > 0) {
            alert("There is an account already registered with this email account")
        }
        conn.close(function() {
            // console.log("closed the function /login");
        });
    });
});

however, what I am trying to do is check if either the username or the email address exist already. If so, then alert. But that requires me to do two sql queries in one. Is this possible with the current setup I have?

I guess i would need something like:

select * from users where username && email = ?
 ...
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You would simply check that the input doesn't exist in either column SELECT COUNT(*) FROM users where username = $inputUserName OR email = $inputUserName

about 4 years ago · Juan Pablo Isaza Denunciar

0

Use the OR operator: https://www.geeksforgeeks.org/sql-and-and-or-operators/

SELECT * FROM Users WHERE username = ... OR email = ...

about 4 years ago · Juan Pablo Isaza Denunciar
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