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
/ @javacodejunkie
Do you want to learn more about Java and how you can grow your skills as a Java Developer? SUBSCRIBE and ring that bell!
On this page of the site you can watch the video online Create View | MariaDB Tutorial for Beginners with a duration of hours minute second in good quality, which was uploaded by the user Java Code Junkie 03 April 2021, share the link with friends and acquaintances, this video has already been watched 6,596 times on youtube and it was liked by 136 viewers. Enjoy your viewing!