Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8133065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:29:57+00:00 2026-06-06T09:29:57+00:00

I am having a table which has the fields: staff_id , leave_applied_from , leave_applied_to

  • 0

I am having a table which has the fields: staff_id, leave_applied_from, leave_applied_to.

+----------+--------------+------------+
| staff_id | applied_from | applied_to |
+----------+--------------+------------+
|     1    | 2012-06-21   | 2012-06-21 |
|     2    | 2012-06-21   | 2012-06-23 |
+----------+--------------+------------+

So the requirement is, If the staff_id 1 tries to enter the date 2012-06-21 it should not allow to enter it, if staff_id 2 tries to enter the date 2012-06-22 it should not allow the staff to enter.

I know how to show errors in PHP side, but I don’t know how to check the database whether the date is there in the DB, I don’t know how to check both the fields in one single MySQL query.

The query should check for staff_id first and then both the other fields(applied_from, applied_to). If the staff has entered the same date range already it should give error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T09:29:59+00:00Added an answer on June 6, 2026 at 9:29 am

    Please try the below:

    SELECT * from tbl where (applied_from =< @inputdate AND applied_to >= @inputdate) 
    AND staff_id=@inputid
    

    If the query returns record, that means the key in date is within range and you could prompt error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a table which has about 17 fields. I need to perform
I have a table in database that is having some fields one of which
My table is having four fields in which two fields are unique. They are
i have a table which has many fields but i want to get count
I'm having a table in which i'm creating a label dynamically. '<td>' + '<label
I am having trouble with Subsonic 3.0 generating an object for a table which
I'm having a table and i have a row which is initially set to
I am having .sql (sybase) file which creates the table i.e. Create_table_mytable.sql But before
i have bookings table which has two people- i want to return person_1 as
I have a nice clean UI within a table view which has a few

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.