I am creating a view for a database for an assignment,
i keep getting this error in my code though.
CREATE VIEW Rental_View
SELECT Mo.Movie_ID, copy_id, mo.Movie_Name, format_name
FROM Movies AS mo JOIN copies AS co
ON mo.Movie_ID = co.movie_id
JOIN format AS fo
ON co.Format_id = fo.format_id
SELECT c.customer_id, rental_ID, DATEDIFF (day, rental_date, return_date) AS rental_duration' , c.first_name + ' ' + c.last_name AS customer_name
FROM Customers AS c INNER JOIN rentals AS r
ON c.customer_ID = r.customer_ID
In the first SELECT statement it is underlined red and i get the error
“Incorrect syntax near the keyword ‘SELECT’.”
i literally have no idea how to correct this as i am fairly new to SQL, any help would be much appreciated.
thanks in advance.
You need the
ASkeyword:If you want to combine the two
SELECTin one, you need toJOINthe tables from both, with something like this: