某表
若干字段 存的都是数字 一个字段是日期,即每一行记录的所有数字都属于这个日期的a--------------b----------c---------d---------e-----------f-------date
78-------------50---------70--------7890------782---------8-------2009-10-20
查询结果要变成
2009-10-20------ 78
2009-10-20------ 50
2009-10-20------ 70
2009-10-20------ 7890
2009-10-20------ 782
2009-10-20------ 8
若干字段 存的都是数字 一个字段是日期,即每一行记录的所有数字都属于这个日期的a--------------b----------c---------d---------e-----------f-------date
78-------------50---------70--------7890------782---------8-------2009-10-20
查询结果要变成
2009-10-20------ 78
2009-10-20------ 50
2009-10-20------ 70
2009-10-20------ 7890
2009-10-20------ 782
2009-10-20------ 8
解决方案 »
- mysql主库Binlog_DO_DB中同步的数据库显示2次
- 删除重复记录
- mysql外键约束
- mysql连接问题。localhost能连接,127.0.0.1能连接,但是通过我的局域网192.168.1.111
- 如何让我安装在linux上得mysql(version:4.1.14)数据库支持中文?
- 如何将图片存入到mysql数据库中?
- 关天SQL Server 和 mysql 的问题,在线提高,急
- 如果获取LAST_INSERT_ID()数据
- sql 语句如何让所有序号减固定值
- 要插入5000条数据,运行时总是报错
- myisam的某一个表老是出错
- mysql4.0安装后是什么样子的样子?疑惑!
union all
select `date`,b
union all
select `date`,c
union all
select `date`,d
union all
select `date`,e
union all
select `date`,f
order by `date`;
union all
select `date`,b from 表t
union all
select `date`,c from 表t
union all
select `date`,d from 表t
union all
select `date`,e from 表t
union all
select `date`,f from 表t
order by `date`;
select *
from(
select `date`,a as num from 表t
union all
select `date`,b from 表t
union all
select `date`,c from 表t
union all
select `date`,d from 表t
union all
select `date`,e from 表t
union all
select `date`,f from 表t
) t
where `date`=xxx
order by `date`但如果是其他数字列的话,要每个都加上条件
建议在每个后加WHERER这样速度会快一些。
+------+--------+
| id | userid |
+------+--------+
| 1 | 3 |
| 2 | 3 |
| 3 | 3 |
| 1 | 3 |
+------+--------+
4 rows in set (0.00 sec)mysql> select group_concat(id) from user group by userid;
+------------------+
| group_concat(id) |
+------------------+
| 1,2,3,1 |
+------------------+
1 row in set (0.00 sec)典型的列转行