title: Make a SQL for exclude certain data
body: <p>I have a somewhat far-fetched question I want to know if there is any way to solve it:</p>
  <p>I have a table called PRODUCTS with these attributes:</p>
  <pre><code>ID, NAME, DATE
  </code></pre>
  <p>I have a table called PRODUCTS_STATUS with these attributes:</p>
  <pre><code>ID, PRODUCT_ID, STATUS_ID, DATE
  </code></pre>
  <p>I have a table called STATES with these attributes:</p>
  <pre><code>ID, STATUS_NAME
  </code></pre>
  <p>Now, as you have seen, it will be about:
  STATES_PRODUCTS will have many STATES of PRODUCTS and STATUS will be many times in PRODUCT_STATUS
  This means that PRODUCT_STATUS has a many-to-many relationship between states and products, since a PRODUCT will go through different state transitions.</p>
  <p>Perfect up to there, it turns out that I have this case suppose:</p>
  <p>PRODUCTS_STATES</p>
  <pre><code>ID, PRODUCT_ID, STATUS_ID, DATE
  1      1            1      00:00:00
  2      2            1      00:00:00
  3      3            1      00:00:00
  4      1            5      00:00:00
  </code></pre>
  <p>I am doing a query at the moment between PRODUCTS and PRODUCT_STATUS, at first I made a query where I told him to show me all the PRODUCTS that have in PRODUCT_STATUS the STATUS_ID= 1</p>
  <p>But if you realize for example the PRODUCT_ID is twice in the table PRODUCT_STATUS with the STATUS_ID = 1 and 5</p>
  <p>Ask:</p>
  <p>Is it possible to make a query where it shows me all PRODUCTS with PRODUCT_STATUS equal to 1 but where PRODUCTS_ID that already has another state are excluded?</p>
  <p>that is, for this example, I want to know if we could see PRODUCTS 2 and 3 because if they see 1 it already has another state.</p>
  <p>Notice I have this query made but it is not useful for what I want:</p>
  <pre><code>   SELECT
      *
     FROM
     products
     inner join product_status in products.id = product_status.product_id
     WHERE
     product_status.status_id not IN ( 
     SELECT
     product_status.id_status
     FROM
     product_status
     WHERE
     product_status.id_status = 5
  
     )
  </code></pre>
  <p>Obviously they will realize that the query returns all the products with STATUS_ID = 1 but I no longer want to see PRODUCT 1 because I am no longer interested.
  I would like to exclude all those PRODUCTS that have 1 and 5.</p>
  <p>I hope you can give me an idea of ​​how it is done. Thanks.</p>