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!
Смотрите видео Create View | MariaDB Tutorial for Beginners онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Java Code Junkie 03 Апрель 2021, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 5,110 раз и оно понравилось 106 людям.