mysql 一道小题
表名为table的表内容如下
Year month value
2009 1 1.1
2009 2 1.2
2009 3 1.3
2009 4 1.4
2010 1 2.1
2010 2 2.2
2010 3 2.3
2010 4 2.4
要求查询结果为
year m1 m2 m3 m4
2009 1.1 1.2 1.3 1.4
2010 2.1 2.2 2.3 2.4
mysql> select year,sum(case when month=1 then value end) as 'm1',sum(case when m
onth=2 then value end) as 'm2',sum(case when month=3 then value end)as 'm3' from
table2 group by year;
相关文档:
1. -static 13%
--with-client-ldflags=-all-static
--with-mysqld-ldflags=-all-static
静态链接提高13%性能
2. -pgcc 1%
CFLAGS="-O3 -mpentiumpro -mstack-align-double" CXX=gcc \
CXXFLAGS="-O3 -mpentiumpro -mstack-alig ......
最近在做PHP与数据库交互的project,急于求成,模仿了下例子就开始动手,结果误把mysql_fetch_array写成了mysql_fetch_row,囧事来了,发现返回的数组居然是index=>value的形式,而明明记得是field name=>value的哈,查手册才明白。
1. mysql_fetch_array的函数原型是
array mysql_fetch_array ( resour ......
前一直没注意这一点,突然一闪念想起来,下面唠唠:
比方说有一个文章表,我们要实现某个类别下按时间倒序列表显示功能:
SELECT * from articles WHERE category_id = … ORDER BY created DESC LIMIT …
这样的查询很常见,基本上不管什么应用里都能找出一大把类似的SQL来,学院派的读者看到上面的S ......