Will the following create view statement successfully create a view of this select? If not, why?

mysql> SELECT * FROM friends;

The following select statement will return the id, username, friend’s name and birthdate of any user that is also a friend whose birthday falls in the current month.

SELECT users.id, users.name, friends.name, friends.birthdate
FROM users JOIN friends ON users.id = friends.userid
WHERE MONTH{friends.birthdate} = MONTH{CURDATE}}

Will the following create view statement successfully create a view of this select? If not, why?

mysql> SELECT * FROM friends;

The following select statement will return the id, username, friend’s name and birthdate of any user that is also a friend whose birthday falls in the current month.

SELECT users.id, users.name, friends.name, friends.birthdate
FROM users JOIN friends ON users.id = friends.userid
WHERE MONTH{friends.birthdate} = MONTH{CURDATE}}

Will the following create view statement successfully create a view of this select? If not, why?

A.
Yes.

B.
No; all column names within a view must be unique.

C.
No; the syntax is incorrect.

D.
No; functions with variable output like curdate may not be used with views.

Explanation:
SELECT Statement shown here is incorrect, has No FROM or JOIN clauses.



Leave a Reply 2

Your email address will not be published. Required fields are marked *


Siwei

Siwei

The CREATE statement missing is:

CREATE VIEW currentBirthdays AS SELECT
users.id, users.name, friends.name, friends.birthdate
WHERE MONTH(friends.birthdate J = MONTH(CURDATE()}

joe bloggs

joe bloggs

B is correct answer