There are two tables
1) Orders id - int name - string 2) orders_products id - int order_id - int product_id - int status - id Order status = minimum status for a product located in that order. Example:
orders id = 1 name = заказ№1 id = 2 name = заказ№2 orders_products id = 1 order_id = 1 status = 1 id = 2 order_id = 1 status = 2 id = 3 order_id = 2 status = 2 id = 4 order_id = 2 status = 5 How to get a list of orders whose status is 1?