There are several differences. First, it creates a VIEW , not just a select statement:
CREATE VIEW NumberOfCoursePerProgram AS
After creating the view, you can query the view in the same way as the table:
SELECT * FROM NumberOfCoursePerProgram;
Secondly, it uses ANSI JOIN, not the implied JOIN. His method is more modern and, most likely, considered more correct by today's standards:
JOIN ProgramCourse pc ON pc.ProgramID = p.ID JOIN Course c ON c.ID= pc.CourseID
Instead
FROM Course, Program, ProgramCourse
Also note that it assigns table aliases when referencing a table:
FROM Program p
p at the end allows you to replace p instead of specifying the entire name of the Program table elsewhere in the query. For example, now you can say WHERE p.Foo > 5 , and not WHERE Program.Foo > 5 . In this case, it is just a shortcut and saves a few characters. However, suppose you referenced the same table twice (for example, JOINING on two different rows in the same table). In this case, you may need to provide aliases for each table in order to eliminate which one is.
source share