Joins are used when you need data from multiple tables at the same time. Please note that there must be a foreign key (FK) defined.
You can use as many tables as you need, but I'll give you a simple example with only 2 tables.
Let's say you have 2 tables: users and user_info.
In the users table you have: id, username and password
In the user_info table you have: id, name, age, email, address, phone, and user_id (FK)
If for a logged in user you want to display his info (let's say an account page), you'll need to use join.
For example:
SELECT ui.name, ui.age, ui.email
FROM user_info AS ui
JOIN users as u
ON u.id = ui.user_id
WHERE u.id=1
Joins are used when you need data from multiple tables at the same time. Please note that there must be a foreign key (FK) defined.
You can use as many tables as you need, but I'll give you a simple example with only 2 tables.
Let's say you have 2 tables: users and user_info.
In the users table you have: id, username and password
In the user_info table you have: id, name, age, email, address, phone, and user_id (FK)
If for a logged in user you want to display his info (let's say an account page), you'll need to use join.
For example:
Some references:
1. Validate SQL query: (https://www.eversql.com/sql-syntax-check-validator/)
2. SQL Join Types: (https://www.w3schools.com/sql/sql_join.asp)