Advertisement
Guest User

sql joins

a guest
May 28th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. SELECT
  2. categoria_nome
  3. , usuario_nome
  4. , inscricao_num_equipes
  5. FROM categorias
  6. CROSS JOIN usuarios
  7. RIGHT JOIN inscricoes ON inscricao_categoria_fk = categoria_pk;
  8.  
  9.  
  10. O resultado deveria ser:
  11.  
  12. Cat 1 - Mestre Yoda - 3
  13. cat 1 - Luke Skywalker - 1
  14. Cat 1 - Obi-wan Kenobi - 7
  15.  
  16. Cat 2 - Mestre Yoda - 0
  17. Cat 2 - Luke Skywalker 2
  18. Cat 2 - Obi-wan Kenobi 1
  19.  
  20. Cat 2 - Mestre Yoda - 1
  21. Cat 2 - Luke Skywalker 2
  22. Cat 2 - Obi-wan Kenobi 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement