posts - 82, comments - 269, trackbacks - 0, articles - 1
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

MySQL查询不含周末的五天前的日期

Posted on 2007-10-26 20:26 itspy 阅读(271) 评论(0)  编辑  收藏
来源:http://database.ctocio.com.cn/askexperts/216/7618716.shtml?ticket=ST-1398-lQWKhI5ZqQLqVscF67h8

select distinct
       cust.fname
     , cust.lname
     , cust.phone
  from orders as o
inner
  join customers as cust
    on cust.id = orders.cust_id
 where o.date_ordered =
       date_sub( current_date
               , interval
       7 - 2 * floor(dayofweek(current_date)/7)
         + floor((dayofweek(current_date)-2)/7)
                     day )
   and o.date_shipped is null

只有注册用户登录后才能发表评论。


网站导航: