Check constraint age 18<
0
votes
1
answer
1227
views
Hello I need to create a constraint that chekc the user is 18< before listenning to certain songs but idk how... I tried this :
ALTER TABLE Historique_ecoute
DROP CONSTRAINT IF EXISTS majorite_utilisateur
GO
ALTER TABLE Historique_ecoute
ADD CONSTRAINT majorite_utilisateur
CHECK (not (DATEDIFF(yyyy, Utilisateurs.Date_naissance, GETDATE()) < 18)
AND REFmusic = ( select IDmusic FROM Catalogue Where censure = 'YES') )
But I get thoses messages :
Msg 1046, Level 15, State 1, Line 244
Subqueries are not allowed in this context. Only scalar expressions are allowed.
Msg 4104, Level 16, State 1, Line 255
The multi-part identifier "Catalogue.annee" could not be bound.
Asked by Ohmy Zala
(3 rep)
May 28, 2020, 12:35 PM
Last activity: May 28, 2020, 02:31 PM
Last activity: May 28, 2020, 02:31 PM