0 votes
in MariaDB by
Why do we use FROM clause with SELECT statement?

1 Answer

0 votes
by
The FROM clause is used with SELECT statement to retrieve data from the table. It is also used to join tables.

Syntax:

SELECT columns_names FROM table_name;      

Example

Let's retrieve all employees from the table "Employees".

SELECT * FROM Employees;   

Output

Mariadb From clause 1

As we know that FROM clause used along with the SELECT clause to join the data of two tables too.

MariaDB Join 1

Let's take an example of INNER JOIN: one of the most common types of join which returns all rows from multiple tables where the join condition is satisfied.

We have two tables "Student" and "Employee".

MariaDB Join 2 MariaDB Join 3

Use the following syntax to join both tables according to the given parameters:

SELECT Students.student_id, Students.student_name, Employee.salary    

FROM Students     

INNER JOIN Employee  

ON Students.student_id = Employee.emp_id;     

Output:

MariaDB Join 4
...