 Welcome back MechanicalEI! Did you know that virtual tables help convert phrases like the ones we used to interact with our Alexa or Google Home devices into retrieval keys possessed by a database? This makes us wonder, how are virtual tables in SQL used? Before we jump in, check out the previous part of this series to learn about what data manipulation commands are. In SQL, a view is a virtual table based on the result set of an SQL statement. It contains both rows and columns, just like a real table, and hence the name virtual table. The fields in a view are fields from one or more real tables in the database. You can add SQL functions where and join to a view and present the data as if the data were coming from one single table. There are three major commands when it comes to using virtual tables or views in SQL. First is the createView command. It creates a new virtual table and it always shows up-to-date data. The database engine recreates the data using the views SQL statement every time a user queries a view. The syntax for createView involves a view name, column names to be viewed, table name and a condition. For example, this SQL command creates a view that shows all customers from India. Second comes updating a view. It can be carried out using the create or replaceView command. The syntax involves a view name, columns, table name and the condition which needs to be updated. This example adds a city column to the Indian customer's view. Third is the dropView command which is used to delete a view. Its syntax is relatively simple and involves only the view name. Continuing from the previous examples, the following command simply drops the Indian customer's view. A subquery also known as a nested query or subselect is a select query embedded within the where or having clause of another SQL query. The data returned by the subquery is used by the outer statement in the same way a literal value would be used. Subqueries are most frequently used with select statement. The following statement will return the details of only those customers whose order value in the order table is more than $5,000. Subqueries can also be used with insert statements. The above statement will insert the records of premium customers into a table called premium customers by using the data returned from the subquery. Here, the premium customers are customers who had placed orders worth more than $5,000. You can also use the subqueries in conjunction with the update statement to update the single or multiple columns in a table. The above statement will update the order value in the order table for those customers who live in the area whose postal code is $100,000 by increasing the current order value by $10. Similarly, you can use the subqueries in conjunction with the delete statement to delete the single or multiple rows in a table. The SQL statement in the example above will delete those orders from the order table that contains the product whose product ID is 3. Hence, we first saw what virtual tables in SQL are and then went on to see what nested queries and complex queries are. In the next episode of Mechanically, find out what translation concept is.