help with sql query

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
greedyisg00d
Forum Commoner
Posts: 42
Joined: Thu Feb 12, 2009 2:48 am

help with sql query

Post by greedyisg00d »

I have a schedule table and it has 3 fields(emp_name,date_from,date_to). This is my scenario, for example the employee greedyisgood is set for a trip from 2009-02-04 up to 2009-02-08 . (YYYY-MM-DD)

date_from = 2009-02-04
date_to = 2009-02-08

Thus when the secretary inputs a specific date 2009-02-06 via textbox for the meeting, the employee greedyisgood will not be shown on the list since the date specified is in between 2009-02-04 up to 2009-02-08. Any idea on how will be the query?

Thanks
User avatar
Salaria
Forum Commoner
Posts: 34
Joined: Fri Feb 13, 2009 2:50 am
Location: India
Contact:

Re: help with sql query

Post by Salaria »

greedyisg00d wrote:I have a schedule table and it has 3 fields(emp_name,date_from,date_to). This is my scenario, for example the employee greedyisgood is set for a trip from 2009-02-04 up to 2009-02-08 . (YYYY-MM-DD)

date_from = 2009-02-04
date_to = 2009-02-08

Thus when the secretary inputs a specific date 2009-02-06 via textbox for the meeting, the employee greedyisgood will not be shown on the list since the date specified is in between 2009-02-04 up to 2009-02-08. Any idea on how will be the query?

Thanks
You can create a query like "SELECT emp_name FROM schedule WHERE date_from < specified_date OR date_to > specified_date;"

It will show only those employees who are not on trip as per your schedule.

Best Regards,
Mahesh Salaria
Post Reply