INNER JOIN media_types ON media_types.MediaTypeId = tracks.MediaTypeId INNER JOIN albums ON Albums.AlbumId = tracks.AlbumId The following query gets data from the tracks, albums, media_types and genres tables in the sample database using the inner join clause. 1) Creating a view to simplify a complex query Let’s take some examples of creating a new view using the CREATE VIEW statement. However, you can assign the names of the view columns that are different from the column name of the table By default, the columns of the view derive from the result set of the SELECT statement. Third, specify a SELECT statement for the view. The view is called a temporary view and SQLite automatically removes the temporary view whenever the database connection is closed. Second, use the the TEMP or TEMPORARY option if you want the view to be only visible in the current database connection. If the view already exists, it does nothing. The IF NOT EXISTS option only creates a new view if it doesn’t exist. To create a view, you use the CREATE VIEW statement as follows: CREATE VIEW view_nameĪS select- statement Code language: SQL (Structured Query Language) ( sql )įirst, specify a name for the view. It means you cannot use INSERT, DELETE, and UPDATE statements to update data in the base tables through the view.
0 Comments
Leave a Reply. |