Creating a view


show more Creating a view provides you with in-depth training on Developer. Taught by Bill Weinman as part of the MySQL Essential Training show less
please wait ...

Creating a view

MySQL supports views, so you can save a query as a view, and use that view like you would a subselect. This is really very simple. For this example, we'll use the database. And here's a useful little query that gets the as minutes and seconds I can say SELECT ID, album_id, title, track_number. And duration DIV 60 AS minutes.

And duration MOD 60 as seconds FROM track. And when I run this, you'll see we have the entire track table. And instead of the duration as a number of seconds we've got it in minutes and seconds. And that's actually pretty useful. Now if I know I'm going to use this query a lot, I can save it as a view. I can simply do this. I can say CREATE VIEW. And name it trackView.

And then here's just an overloading of the as keyword. As. And this is the view itself. I like to put the semicolon on a separate line when I indent like that. It's just me, it's not necessary. And now I can say select asterisk FROM TrackView, as if it were a table, or a sub select. I pr...

Creating a view
Video duration: 3m 32s 4h 24m Beginner

Viewers:

Creating a view provides you with in-depth training on Developer. Taught by Bill Weinman as part of the MySQL Essential Training

Subject:
Developer
Software:
MySQL
Author:
please wait ...