日期:2014-05-16  浏览次数:20683 次

MySql---BIT_COUNT()&BIT_OR()

完全转载:http://msh24.iteye.com/blog/1136449
Java代码??收藏代码
  1. CREATE?TABLE?t1?(year?YEAR(4),?month?INT(2)?UNSIGNED?ZEROFILL,??
  2. ?????????????day?INT(2)?UNSIGNED?ZEROFILL);??
  3. INSERT?INTO?t1?VALUES(2000,1,1),(2000,1,20),(2000,1,30),(2000,2,2),??
  4. ????????????(2000,2,3),(2000,2,3);??
  5. 示例表中含有代表用户访问网页的年-月-日值。可以使用以下查询来确定每个月的访问天数:??
  6. ??
  7. SELECT?year,month,BIT_COUNT(BIT_OR(1<<day))?AS?days?FROM?t1??