Views
3. What views are
Revision

Instruction

Excellent! We have just created the view. How can we use it? Well, a view is a virtual table: it has its name, some columns and rows, like any other table. The view data is not stored physically, every time you retrieve data from the view, the database reruns the underlying query.

We can use a view in our queries just as we use other tables. Take a look:

SELECT * FROM course_lecturer;

The above query will select all the information for courses together with their lecturers.

Exercise

Show all information for current courses only. Use the view course_lecturer. A current course is a course which has a date in the field course_next_edition (i.e. the field is not null).

Stuck? Here's a hint!

Type

SELECT * FROM course_lecturer 
WHERE course_next_edition IS NOT NULL;

Console

Code editor

Result

TableConsole