Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. create table article
  2. (
  3.     id      int
  4.         constraint article_pk
  5.             primary key,
  6.     subject text,
  7.     body    text
  8. );
  9.  
  10. create table tag
  11. (
  12.     id   int
  13.         constraint tag_pk
  14.             primary key,
  15.     name text
  16.  
  17. );
  18.  
  19. create table article_tag
  20. (
  21.     tag_id     int,
  22.     article_id int
  23.  
  24. );
  25.  
  26. SELECT a.subject, t.name
  27. FROM article a
  28. LEFT JOIN article_tag at ON a.id = at.article_id
  29. LEFT JOIN tag t ON t.id = at.tag_id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement