Create View | MariaDB Tutorial for Beginners



Create View | MariaDB Tutorial for Beginners

Create View | MariaDB Tutorial for Beginners

In this MariaDB tutorial for beginners, we are going to learn how to use the CREATE VIEW command. A view is the result set of a stored query on a database. In this tutorial we will create three views.

1. A MariaDB view composed of a single table
2. A MariaDB view composed of two tables with LEFT JOIN
3. A MariaDB view composed of two tables with a LEFT JOIN and a WHERE clause

Here are the three DDL commands for the views that were created in this tutorial.

CREATE VIEW
employee_list1 AS
SELECT employee_id, last_name, first_name
FROM employees
ORDER BY last_name, first_name;

CREATE VIEW
employee_list2 AS
SELECT e.employee_id as ‘ID’, e.last_name as ‘LAST NAME’, e.first_name as ‘FIRST NAME’ , d.text as ‘DEPARTMENT’
FROM employees e
LEFT JOIN departments d on(e.dept_id = d.id)
ORDER BY department, last_name, first_name;

CREATE VIEW
employee_list3 AS
SELECT e.employee_id as ‘ID’, e.last_name as ‘LAST NAME’, e.first_name as ‘FIRST NAME’ , d.text as ‘DEPARTMENT’
FROM employees e
LEFT JOIN departments d on(e.dept_id = d.id)
WHERE e.dept_id = 2;

========================================================

Check out my YouTube Channel for more FREE videos
https://www.youtube.com/channel/UCaB4hPBfWIR_mOFxMamBqrQ

Do you want to learn more about Java and how you can grow your skills as a Java Developer? SUBSCRIBE and ring that bell!