表A
id sex Name .......
1 1 a
2 2 b
3 1 c
4 2 d
表B
id Aid score ........
1 1 123
2 3 234
3 2 345
4 4 456期望结果
sex1Name score1 sex2Name score2
a 123 b 345
c 234 d 456多谢个为大侠
id sex Name .......
1 1 a
2 2 b
3 1 c
4 2 d
表B
id Aid score ........
1 1 123
2 3 234
3 2 345
4 4 456期望结果
sex1Name score1 sex2Name score2
a 123 b 345
c 234 d 456多谢个为大侠
解决方案 »
- 在查询语句中如何增加序号字段(利用临时表)
- 有没有给java做过web service的,需不需要特殊处理一下?
- 求delphi的格式验证函数
- 大家来帮忙分析一下代码:关于窗体类继承中Create;overload部分引起 子窗体不能创建!!! 高分!!
- 有两个列表框,相互比较各自的条目,若listbox1列表框中的条目没有和listbox2列表框中的条目相对应,则把listbox1列表框中该条目清除。不
- 100分,求“传奇”源码
- 高分问一个简单的问题!
- ADO的臭虫、问题太多,只好用BDE了
- c/s结构中的数据提交问题
- csdn下载软件我怎么下在不起?
- 文件真正的创建时间
- 寻delphi程序员合作,最好是开发过股票软件
思路可参考:
http://topic.csdn.net/t/20050923/08/4288492.html
mysql的sql也可以用case when then的
c 234 d 456
这个咚咚 为啥要折行?
测试用SQL:create table test1 (id integer,sex integer,Name varchar(10));
insert into test1 values(1, 1, 'a');
insert into test1 values(2, 2, 'b');
insert into test1 values(3, 1, 'c');
insert into test1 values(4, 2, 'd');
create table test2(id integer, Aid integer,score integer);
insert into test2 values(1,1,123);
insert into test2 values(2,3,234);
insert into test2 values(3,2,345);
insert into test2 values(4,4,456);查询SQLselect c.name as sex1Name,c.score as score1, d.name as sex2Name,d.score as score2 from
(select a.id, a.name,b.score
from test1 a,test2 b where a.id=b.id and a.id%2=1) c,
(select a.id, a.name,b.score
from test1 a,test2 b where a.id=b.id and a.id%2=0) d
where c.id=d.id-1;结果:
+----------+--------+----------+--------+
| sex1Name | score1 | sex2Name | score2 |
+----------+--------+----------+--------+
| a | 123 | b | 234 |
| c | 345 | d | 456 |
+----------+--------+----------+--------+
2 rows in set (0.00 sec)
同样问题在mysql板块发布已经揭贴