DEV Community

Lam
Lam

Posted on

2 1

Sql Joins Cheat Sheet

Diagram

SELECT * FROM `A` INNER JOIN `B`
Enter fullscreen mode Exit fullscreen mode
┌────────┐
│ A  ┌───┼────┐
│    │ ∩ │    │
└────┼───┘  B │
     └────────┘
Enter fullscreen mode Exit fullscreen mode
Join What
Inner join
Left outer join A +
Right outer join + B
Full outer join A + + B

Example

SELECT * FROM order_items \
  LEFT OUTER JOIN orders \
  ON order_items.order_id = orders.id
Enter fullscreen mode Exit fullscreen mode

Joins are typically added to SELECT statements to add more columns and records.

Reference

Top comments (1)

Collapse
 
socoladaica profile image

Advanced

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay