1 2 3 4 |
SELECT distinct id FROM `members` where birthday is not null and month(birthday) >= 9 and day(birthday) >= 1 and month(birthday) <= 10 and day(birthday) <= 31 |
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
function add_members($coupon_id, $bd_from, $bd_to){ $sql = "insert into `coupon_bd_members` (coupon_id, member_id, created_at) (SELECT distinct ?, id, ? FROM `members` where birthday is not null and month(birthday) >= ? and day(birthday) >= ? and month(birthday) <= ? and day(birthday) <= ? )"; $from = Carbon::parse($bd_from); $to = Carbon::parse($bd_to); $values = [ $coupon_id, Carbon::now()->toDateTimeString(), $from->month, $from->day, $to->month, $to->day ]; $result = $this->db->query($sql, $values); //logg($this->db->last_query()); return $result; } |