Profile picture for user arilio666

A VIEW creation in MySQL is sort of like a virtual table derived from a query. You can think of it as aliasing a whole query with a custom table name to make it display with a single query instead of doing the same conditions all over again.

Using CREATE VIEW a virtual view of the query is created in an instance.


CREATE VIEW AS View_Name Our Query For The View;


Let us see it in action

select office_id, city from offices where city like 'N%';

  • So this query gets the City name which starts with the letter N as you can see clearly from the query.
  • Now let us create a view for this.
create view idCity as select office_id, city from offices where city like 'N%';

Here I have created idCity view for the whole query which can then be called upon to be displayed.

As we can see it is a sort of aliasing method for the whole query we write just for the sake of convenience to write the query more neatly.