How to join two tables in sql?

Example:

-- Attempting to join 'orders' and 'customers' without specifying a common column
SELECT orders.order_id, customers.customer_name
FROM orders, customers;
Solution:

-- Correctly joining 'orders' and 'customers' on customer_id
SELECT orders.order_id, customers.customer_name
FROM orders
JOIN customers ON orders.customer_id = customers.customer_id;
Joining tables requires specifying a common column. In this case, we're using the customer_id column to join the orders and customers tables together.

Beginner's Guide to SQL