SELECT Customers.customer_id, Customers.first_name, Orders.amount
FROM Customers
INNER JOIN Orders
ON Customers.customer_id = Orders.customer
WHERE Orders.amount >= 500;
-- Rows with ID existing in both a, b and c
-- JOIN is equivalent to INNER JOIN
SELECT a.ID, a.NAME, b.VALUE1, c.VALUE1 FROM table1 a
JOIN table2 b ON a.ID = b.ID
JOIN table3 c ON a.ID = c.ID
WHERE a.ID >= 1000;
-- ⇓ Test it ⇓ (Fiddle source link)
SELECT columns
FROM table1
INNER JOIN table2
ON table1.column_name = table2.column_name;
SELECT
customer.customer_id,
first_name,
last_name,
amount,
payment_date
FROM
customer
INNER JOIN payment
ON payment.customer_id = customer.customer_id
ORDER BY payment_date;
Bahasa kode: SQL (Structured Query Language) ( sql )
SELECT
customer.customer_id,
first_name,
last_name,
amount,
payment_date
FROM
customer
INNER JOIN payment
ON payment.customer_id = customer.customer_id
ORDER BY payment_date;
Code language: SQL (Structured Query Language) (sql)
SELECT Customers.customer_id, Customers.first_name, Orders.amount
FROM Customers
INNER JOIN Orders
ON Customers.customer_id = Orders.customer;
INNER JOIN is used when retrieving data from
multiple tables and will return only matching data.
example=
Select P.FIRST_NAME , M.DRUG_ID
FROM PATIENTS P
INNER JOIN MEDICATIONS M ON P.PATIENTS_ID = M.PATIENTS_ID
SELECT character.name, inventory.id
FROM charactercreator_character AS character,
charactercreator_character_inventory AS inventory
WHERE character.character_id = inventory.character_id;
SELECT field1, CASE field2
WHEN condition1 THEN 'result1'
WHEN condition2 THEN 'result2'
ELSE 'result'
END, field3
FROM table_name;
select *
from toys
join bricks
on toy_id > brick_id;
/*The INNER JOIN keyword selects records that have matching values in both
tables.
*/
INNER JOIN Syntax
SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name = table2.column_name;
SELECT
product_name,
category_name,
list_price
FROM
production.products p
INNER JOIN production.categories c
ON c.category_id = p.category_id
ORDER BY
product_name DESC;
Code language: SQL (Structured Query Language) (sql)