Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT PAPA.idPAPA AS PAPA, HIJO.idHIJO AS HIJO, NIETO.idNIETO AS NIETO,
- BISNIETO.idBISNIETO AS BISNIETO
- FROM PAPA
- LEFT JOIN HIJO ON HIJO.PreH=PAPA.idPAPA
- LEFT JOIN NIETO ON NIETO.PreN=HIJO.idHIJO
- LEFT JOIN BISNIETO ON BISNIETO.PreB=NIETO.idNIETO
- ORDER BY idPAPA,idHIJO,idNIETO,idBISNIETO ASC;
- SELECT idPAPA, idHIJO, idNIETO, idBISNIETO
- FROM
- (SELECT PAPA.idPAPA AS PAPA, HIJO.idHIJO AS HIJO,NIETO.idNIETO AS
- NIETO,BISNIETO.idBISNIETO AS BISNIETO
- FROM PAPA
- LEFT JOIN HIJO ON HIJO.PreH=PAPA.idPAPA
- LEFT JOIN NIETO ON NIETO.PreN=HIJO.idHIJO
- LEFT JOIN BISNIETO ON BISNIETO.PreB=NIETO.idNIETO
- WHERE idPAPA="A"
- ) ORDER BY idPAPA,idHIJO,idNIETO,idBISNIETO ASC
- ;
Add Comment
Please, Sign In to add comment