Browse Source

add left join

Daniel Sheffield 5 months ago
parent
commit
4570b10da7
1 changed files with 2 additions and 2 deletions
  1. 2 2
      example.sql

+ 2 - 2
example.sql

@@ -1,6 +1,6 @@
 -- Insert a tag if it got missed
 -- Insert a tag if it got missed
 --INSERT INTO tags_map (transaction_id, tag_id) VALUES(2247, 11);
 --INSERT INTO tags_map (transaction_id, tag_id) VALUES(2247, 11);
 SELECT * FROM transactions t
 SELECT * FROM transactions t
-	JOIN tags_map ON (transaction_id = t.id)
-	JOIN tags tg ON (tag_id = tg.id)
+	LEFT JOIN tags_map ON (transaction_id = t.id)
+	LEFT JOIN tags tg ON (tag_id = tg.id)
 	WHERE transaction_id = 2247;
 	WHERE transaction_id = 2247;