更新时间:2023-02-24 18:30:05
您需要一个检查约束。
ALTER TABLE [TableName] ADD CONSTRAINT
my_constraint CHECK (PatientType = 'Admitted' OR PatientType = 'OPD')
你需要检查它是否可以在MySQL中运行,特别是从今天开始。
看起来不行至少它不是几年前)。
You need to check if it works though in MySQL in particular as of today.
Seems it does not work (or at least it did not a few years ago).
不确定是否已修复。
如果不工作,请使用触发器而不是检查约束。
If not working, use a trigger instead of a check constraint.