How can I do a constraint/trigger to check a value from another table for example

CHECK

tblAcademic.role = 1 and [currentable].post = 1

Please help

Something like this i need

CREATE TRIGGER testref BEFORE INSERT ON academic_role
FOR EACH ROW BEGIN
if (Select Senior_Post_Required from role_type where roleID = new.RoleID) = 1 AND
if (Select Senior from post_type where post_typeID = (Select Post_TypeID from Academic_Post where academicID = new.AcademicID)) = 1 then
INSERT INTO `academic_role` (`Role_typeId`, `AcademicID`, `DepartmentID`, `ExtraSalary`, `StartDate`) VALUES
(5, 6, 2, 80, '1999-01-21 00:00:00'),
END;


But I dont know the right sytnax for the IF

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.