problema consulta con tres tablas
Hola, le he dado una vuelta al problema que tengo y le he dado otro planteamiento:
Tengo tres tablas:
TABLA 1 - usuarios
id | nombre
---+----------
1 | jonh
2 | laura
3 | george
TABLA 2 - servicios
id | nombre
---+----------
1 | breakfast
2 | lunch
3 | dinner
TABLA 3 - relación usuarios-servicios
id | id_user | id_servicio
---+---------+--------------
1 | 1 | 1
2 | 1 | 2
3 | 1 | 3
4 | 2 | 1
5 | 2 | 2
6 | 3 | 3
Y necesito saber, usuario por usuario las correspondencias o no correspondencias entre usuario y servicios tal que así:
Para john:
john | breakfast
john | lunch
john | dinner
Para laura:
laura | breakfast
laura | lunch
NULL | dinner
Para george:
NULL | breakfast
NULL | lunch
george | dinner
El RIGHT JOIN no funciona porque discrimino por usuario.
Y con el producto cartesiano no lo logro hacer.
Alguna idea?
salu2
Subject
Views
Written By
Posted
problema consulta con tres tablas
1120
July 20, 2016 03:59PM
545
July 23, 2016 07:45PM
501
July 25, 2016 03:29AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.