Lets say i have two tables, one for products and other for OrderDetails. I'm trying to make a check constraint that checking whether the user had inputted a number of quantity inside the OrderDetails table that has exceeded the number of quantity inside the Product table or not.
I tried to use a REFERENCES clause to refer to the other table but i didn't work. and i guess its only working for the foreign key constraint. So, if there's any other ways provided to make the check constraint work that way i would be thankful.
alter table orderdetails add constraint quantity_chck check (quantity <= references products(quantity)) ;