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

118
Vistas
data not get in proper manner which i want in postgresql multiple inner join

i.m trying to do a inner join on two table. 1. users , 2. rides. in user table there are two types of user(0 for user , 1 for driver). and in ride table i store user_id and provide_id which came from users table. so now problem is that i can't get information of both user simultaneously.

SELECT name,mobile, email, name as driverName
FROM users 
INNER JOIN rides  
ON users._id  = rides.user_id
INNER JOIN rides as ride 
ON users._id  = ride.provider_id;

this return me null table.

name number email drivername

and when i use only single join :

SELECT name,mobile, email, name as driverName
FROM users 
INNER JOIN rides  
ON users._id  = rides.user_id```

 it return me name , mobile and email but not drivername.

| name | number | email |drivername |
|:---- |:------:| -----:|----------:|
| xyz  | 000000 | email |           |

i want ouput like this

| name | number | email |drivername |
|:---- |:------:| -----:|----------:|
| xyz  | 000000 | email |  abcsd    |
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I might be inclined to express your query using exists logic:

SELECT u.name, u.mobile, u.email
FROM users u
WHERE EXISTS (SELECT 1 FROM rides r WHERE u._id = r.user_id) AND
      EXISTS (SELECT 1 FROM rides r WHERE u._id = r.provider_id);

This will return every user for whom there is a both a user and provider ride.

about 4 years ago · Santiago Trujillo 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