Aarni Ruuhimäki wrote: > So the WHERE clause would go like: > > group_id = 1 AND res_start_day < '$date1' AND res_end_day >= '$date1' [AND > region_id = $region_id] [AND company_id = $company_id] [AND product_id = > $product_id] > OR > group_id = 1 AND res_start_day = '$date1' AND res_end_day >= '$date1' [AND > region_id = $region_id] [AND company_id = $company_id] [AND product_id = > $product_id] > OR > group_id = 1 AND res_start_day >= '$date1' AND res_start_day < '$date2' AND > res_end_day >= '$date1' [AND region_id = $region_id] [AND company_id = > $company_id] [AND product_id = $product_id] This is smaller; and should be equivalent: group_id = 1 AND ( res_start_day <= '$date1' AND res_end_day >= '$date1' OR res_start_day >= '$date1' AND res_start_day < '$date2' ) [AND region_id = $region_id] [AND company_id = $company_id] [AND product_id = $product_id]
pgsql-sql by date:
Соглашаюсь с условиями обработки персональных данных