Wednesday, 15 May 2013

php - MySQL - Search Query between DATE_SUB() AND DATE_SUB() Error -


I tried between using a search query (PDO php and mysql) date range (7days-7days) I'm using) and (date 1day) for example using: DATE_SUB ():

  end_date 2013-03-26 2013-03-19 and 2013-03-25 '  

If you are using the first question below Dinank_sub (7 day period), but 2013-03-19 ignoring the other (date_sub (1 day interval) and Its search between 2013-03-26

  $ sevd_query = "booking_id, DATE_FO RMAT (start_date, '% e /% c') s_d, DATE_FORMAT (end_date, as selected as '% e /% c') as e_d bb Join bsi_reservation as interiors br from bsi_bookings bb .booking_id = br.bookings_id where Bckc_id =: C_id and: among DATE_SUB (bb.end_date, interval 7 days) and DATE_SUB (bb.end_date, interval 1 day) "day;  

section:

 : DATE_SUB (bb.end_date, interval 7 days) and Day between DATE_SUB (bb.end_date, interval 1 day)   

can be expressed as: day> = (End_date - 7) and day & lt; = (End_date - 1)

which can be rewritten:

  (day + 7)> = End_date and (day + 1) & lt; = End_date   

is the same as:

  end_date & lt; = (Day +7) and end_date & gt; = (Day + 1)   

Whatever:

  end_date> = (Day + 1) and END_DATE & lt; = (Day + 7)   

can also be written as:

  between end_date (day + 1) and (day + 7 )   

Which I do not think you want.

Instead, try this:

  Select Buking_aidi, DATE_FORMAT (start_date, '% e /% c') s_d, DATE_FORMAT (end_date, '% e /% C' aS) as well as bsi_reservation as inner br from e_d bsi_bookings looking on as bb bb.booking_id = br.bookings_id where bc.c_id =: between c_id and Bibi.and_det days - interval 7 days Day: - INTERV AL 1 day;   

If the end_date field is indexed, it will allow the index to be used.

If a field field is in a function to be searched for.

No comments:

Post a Comment