title: MySQL Check constraints: only one column is not null
body: <p>This question is similar to <a href="https://stackoverflow.com/questions/30039973/check-constraint-to-confirm-exactly-one-is-not-null">Check Constraint to Confirm Exactly One is not NULL</a>, but for MySQL and multiple columns, and MySQL supports check since v8.0.16.</p>
  
  <p>For example, I have a "Post" Table and it has three columns which are author_id, manager_id, editor_id. Only one of these three columns should be not null.</p>
  
  <p>How to achieve this in MySQL Check constraints?</p>
  
  <p>Maybe something like</p>
  
  <pre><code>not_null_sum = (author_id is not null ? 1 : 0) + (manager_id is not null ? 1 : 0) + (editor_id is not null ? 1 : 0)
  not_null_sum should == 1
  </code></pre>