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 ......
报错:
/tmp/ccBBJEB8.o: In function `ping_sql':
pingsql.c:(.text+0x7c): undefined reference to `mysql_init'
pingsql.c:(.text+0xe1): undefined reference to `mysql_real_connect'
pingsql.c:(.text+0xff): undefined reference to `mysql_close'
pingsql.c:(.text+0x119): undefined reference to `mys ......
mysql set names 问题
mysql_query("set names 'utf8'");
一直以来总以为set names 是用来设置msyql 的字符集的,最近作个东西才发现自己认识上的错误,
查一下手册
SET NAMES ‘x‘语句与这三个语句等价:
mysql> SET character_set_client = x;
mysql> SET character_set_results = x;
mysql> ......
前一直没注意这一点,突然一闪念想起来,下面唠唠:
比方说有一个文章表,我们要实现某个类别下按时间倒序列表显示功能:
SELECT * from articles WHERE category_id = … ORDER BY created DESC LIMIT …
这样的查询很常见,基本上不管什么应用里都能找出一大把类似的SQL来,学院派的读者看到上面的S ......
MySQL MyIsam 存储引擎在创建索引的时候,索引键长度是有一个较为严格的长度限制的,所有索引键最大长度总和不能超过1000,而且不是实际数据长度的总和,而是索引键字段定义长度的总和。下面做个简单的测试,记录一下。
root@sky:~# mysql -u sky -p -h127.0.0.1
Enter password:
Welcome to the MySQL monitor. Command ......