How to Create View in SQL
In this article I am going to explain how to create view in SQL.
View in SQL is a virtual table and this table is created on the result set of SQL statement. View is similar to a normal table and also have rows and columns. View may be combination of some rows and columns of two or more than two tables. You can use SQL function and WHERE clause with View in SQL statement.
To create view we use CREATE VIEW statement with WHERE clause.
A Statement that create vendors table
create table vendors
Statements that insert data in vendors table
insert into vendors values (20,'vipendra','noida','up')
insert into vendors values (21,'deepak','lucknow','up')
insert into vendors values (22,'rahul','kanpur','up')
insert into vendors values (23,'malay','delhi','delhi')
insert into vendors values (24,'mayank','noida','up')
A Statement that is used to fetch data from vendors table
A Statement that is used to create a view in sql
create view vendordata
where vendorid in (select vendorid from mcninvoices)
A Statement that is used to run view
Output of view vendordata