Mysql query help need

Discussion in 'MySQL' started by tintumon, Jun 20, 2010.

  1. #1
    Hi to all,

    I am developing a booking system .I have problem to get records .

    Scenario is.

    I have a database table where i define two fields arrival_date and departure_date.

    I have a calendar when i move to month beneath the calendar i am showing all records of that month.

    My query is

    SELECT * FROM `roombooking` WHERE arrival_date between '2010-05-01' and '2010-05-31' or departure_date between '2010-05-01' and '2010-05-31'

    it show me all records whose arrival_date or departure_date is between '2010-05-01' and '2010-05-31'

    For example if a person book a room with arrival_date is '2010-05-01' and departure date is '2010-06-01'

    this records should also come in month of may because month of may is between june and july .

    kindly help me
     
    tintumon, Jun 20, 2010 IP
  2. dropcatchsell

    dropcatchsell Active Member

    Messages:
    431
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    60
    #2
    Essentially you're loading all arrivals and departures for the month of May, correct?

    SELECT * FROM `roombooking` WHERE (arrival_date>= '2010-5-1' AND arrival_date<='2010-5-31') OR (departure_date>='2010-5-1' AND departure_date<='2010-5-31')

    That will work.
     
    dropcatchsell, Jun 21, 2010 IP
  3. seofast

    seofast Guest

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    check these MySql Qurey

    select * from 'roombooking'' where (arrival_date>= And arrival_date<=) or (departure_date>='' And departure_date<='')

    Add date and check these query

    and tell me
     
    seofast, Jun 30, 2010 IP