Jump to content

[SOLVED] SQL query - with 4 condition


md2d

Recommended Posts

i have 2 parameters: $start_date and $end_date,

How do I get list project in a range start_date and end_date ?

 

this query view all project,

$que = "SELECT project_id, project_company, project_name FROM projects WHERE

        project_start_date >='$start_date' AND project_end_date <='$end_date' OR

        project_start_date <='$start_date' AND project_end_date <='$end_date' OR

        project_start_date <='$end_date' AND project_end_date >='$end_date' OR

        project_start_date <='$start_date' AND project_end_date >='$end_date'

ORDER BY project_company ASC";

 

but i need to view in a range $start_date and $end_date

 

                |-------?--------|

$start_date <----range------> $end_date

 

anyone know, please help me

 

thanks.

----

md2*

 

Link to comment
https://forums.phpfreaks.com/topic/71317-solved-sql-query-with-4-condition/
Share on other sites

$que = "SELECT project_id, project_company, project_name FROM projects WHERE ((project_start_date >='$start_date' and project_end_date <='$end_date') or (project_start_date <='$end_date' and (('$end_date' <= project_end_date) and (project_end_date <='$end_date'))) or ((('$start_date' <= project_start_date) and (project_start_date <= '$end_date')) and project_end_date >= '$end_date') or (project_start_date <='$start_date' and project_end_date >='$end_date') and project_active='1') ORDER BY project_company ASC";

 

thanks for reply fenway..........

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.