From the course: MySQL Advanced Topics (2019)
Unlock this course with a free trial
Join today to access over 22,600 courses taught by industry experts.
Creating a view - MySQL Tutorial
From the course: MySQL Advanced Topics (2019)
Creating a view
- [Narrator] In MySQL, you can save a query as a view. And you can use that view as if it were a table, this is very simple and very useful. Here we're using the album database again, and I have a simple select here which selects from the track table, and it separates out the minutes and seconds using integer division from the duration column. And when I execute this, you see we get minutes and seconds as if they were separate columns, and they're named m and s. So I'm going to say this is a useful query. I want to save this query. And I can now save this as a view, I just simply say create view. Track view. AS, and then the select statement. As simple as that. When I execute this, that view is now saved, and I can say select asterisk from track view as if it were a table, and I get this result with the minutes and seconds separated out just as I had in my select statement. So my select statement is now saved as a…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.