易截截图软件、单文件、免安装、纯绿色、仅160KB

mysql 行转列问题

这几天所作的工作涉及到数据库行转列的问题
记录一下出现的错误,以免以后再犯
举网上最通俗的例子吧
Name Subject Result
张三    语文         80
张三    数学         90
张三    物理         85
李四    语文         85
李四    数学         92
李四    物理         82
想要的结果
姓名 语文 数学 物理
张三  80  90    85
李四  85  92    82  
正确的写法
select name as 姓名,
max
(case when subject='语文' then result end) as 语文,
max
(case when subject='数学' then result end) as 数学,
max
(case when subject='物理' then result end) as 物理
from T1 group by
name
最开始写的时候不知道max
函数有什么用
而且也没有加
group by
最后的结果是
姓名     语文      数学      物理
张三      80
张三                 90        
张三                             85
李四      85  
李四                 92       
李四                             82
发现结果不对,然后加了
group by语句
结果是
张三      80
李四      85


相关文档:

hibernate mysql映射类型

 
integer 或者 int
int 或者 java.lang.Integer
INTEGER
4 字节
long
long  Long
BIGINT
8 字节
short
short  Short
SMALLINT
2 字节
byte
byte  Byte
TINYINT
1 字节
float
float  Float
FLOAT
4 字节
double
double  Double
DOUBLE
8 字节
b ......

apache和mysql重启命令

 
修改linux服务器的http配置之后,必须重启Apache服务,命令为: /etc/rc.d/init.d/httpd restart
chown -R mysql:mysql 目录名 改变文件属性
mysqladmin -u root -p password 'new password' 设置密码
apt-get remove 删除软件
apt-get clean 清理
/etc/rc.d/init.d/mysqld restart
php 就配置了session 主 ......

11 advanced MySQL questions

 

Explain MySQL architecture
. - The front layer
takes care of network connections and security authentications, the
middle layer does the SQL query parsing, and then the query is handled
off to the storage engine. A storage engine could be either a default
one supp ......

开启 MySQL query cache,加快数据库读取速度

 
在网站建设或者运营中,如果 MySQL server 是非常繁忙,可以开启 query cache 以加速回应时间,开启方法可以在 my.cnf 裡面加入以下项目: (Redhat 下面是 /etc/my.cnf;Debian 是在 etc/mysql
/my.cnf).
query_cache_size = 64M
query_cache_type = 1
query_cache_limit = 1048576
以上语法的设定里面, ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号