How to run MySQL on your mac m1, maybe you can learn it from following link.
First, create test data by the following command:
# 1. Create a database called CompanyDB
CREATE DATABASE IF NOT EXISTS CompanyDB;
USE CompanyDB;
# 2. Create a table called Departments with the following columns:
CREATE TABLE IF NOT EXISTS `Departments` (
`DepartmentID` INT NOT NULL,
`DepartmentName` VARCHAR(50) NOT NULL,
PRIMARY KEY (`DepartmentID`)
);
# 3. Create a table called Employees with the following columns:
CREATE TABLE IF NOT EXISTS `Employees` (
`EmployeeID` INT NOT NULL,
`EmployeeName` VARCHAR(50) NOT NULL,
`DepartmentID` INT,
PRIMARY KEY (`EmployeeID`)
);
# 4. Insert the following data into the Departments table:
INSERT INTO `Departments` (DepartmentID, DepartmentName) VALUES
(1, 'HR'),
(2, 'IT'),
(3, 'Finance'),
(4, 'Operations');
# 5. Insert the following data into the Employees table:
INSERT INTO `Employees` (EmployeeID, EmployeeName, DepartmentID) VALUES
(1, 'Alice', 1),
(2, 'Bob', 2),
(3, 'Charlie', 3),
(4, 'Dana', null);
Second, query the data by the following command:
SELECT Employees.EmployeeName, Departments.DepartmentName
FROM Employees
INNER JOIN Departments ON Employees.DepartmentID = Departments.DepartmentID;
SELECT Employees.EmployeeName, Departments.DepartmentName
FROM Employees
LEFT JOIN Departments ON Employees.DepartmentID = Departments.DepartmentID;
SELECT Employees.EmployeeName, Departments.DepartmentName
FROM Employees
RIGHT JOIN Departments ON Employees.DepartmentID = Departments.DepartmentID;