I am little bit confused about joins in MYSQL?
In what way we can use them?
And how many types are there?
Any help wil be greatly useful........
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.
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