title: Check constraint for a condition in Postgresql
body: <p>I'm trying to create a check constraint to prevent people from changing a <code>sales_status</code> to <code>3</code> unless the <code>progression_status</code> is <code>80</code>.</p>
  
  <p>I thought it was </p>
  
  <pre><code>ALTER TABLE mytable 
     ADD CONSTRAINT sales_status_cant_be_3_for_nonprogressed 
     CHECK (((sales_status = 3 ) or (progression_status &lt; 80)))
  </code></pre>
  
  <p>however this is returning an error saying that some row violates it. When I run the query </p>
  
  <pre><code>select * from mytable where sales_status = 3 and progression_status &lt; 80
  </code></pre>
  
  <p>I get no results as expected. Yet I can't seem to make the check constraint to work</p>