Jump to content

[SOLVED] SQL query - with 4 condition


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..........

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.