I want to create a table which has 2 columns that would only allow one of them to have value in the same row.

I tried with CHECK constraint but it not working correctly

Ex: SQL Fiddle schema example

thanks in advance

1 Answer 1


The CHECK clause is parsed but ignored by all storage engines.

http://dev.mysql.com/doc/refman/5.7/en/create-table.html Use trigger instead.

  • I can't add triggers or procedures in mysql server :( , I'll check this constraint in the application side. Commented Jun 6, 2016 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.