Skip to content

Instantly share code, notes, and snippets.

@tamboer
Created June 6, 2013 12:29
Show Gist options
  • Select an option

  • Save tamboer/5721147 to your computer and use it in GitHub Desktop.

Select an option

Save tamboer/5721147 to your computer and use it in GitHub Desktop.
sql select employees with contracts between two dates
//not tested 100% there should be some <= >= incorporated depending on ...
$q = "SELECT `employees`
FROM `employee_contract`
WHERE start_date
BETWEEN '$from'
AND '$to'
OR end_date
BETWEEN '$from'
AND '$to'
AND start_date < '$from'
OR end_date > '$to'";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment