简体   繁体   中英

how to use not between clause in codeigniter

I don't know what wrong with this query. I am getting error. Can please any one tell me about this.

$this->db->where("ac.booking_date", $booking_date); 
$this->db->where(''.$booking_date .' NOT BETWEEN ac.booking_date AND ac.end_date', null, false); 

A Database Error Occurred

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '10:00 NOT BETWEEN ac.booking_date AND ac.end_date ORDER BY ac . id DESC' at line 7

SELECT ac .*, p . first_name , p . last_name FROM anb_crm_bookings ac LEFT JOIN anb_crm_users_personal_info p ON p . user_id = ac . created_by WHERE ac . email = 'devid00@Gmail.com' AND ac . record_id = '36841' AND ac . booking_date = '2019-05-29 10:00' AND 2019-05-29 10:00 NOT BETWEEN ac.booking_date AND ac.end_date ORDER BY ac . id DESC

Filename: models/BookingModel.php

Line Number: 245

you're forgetting quotes in the 2nd WHERE. Replace it with the following code

 $this->db->where("ac.booking_date", $booking_date); 
 $this->db->where('"'.$booking_date .'" NOT BETWEEN ac.booking_date AND ac.end_date', null, false);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM