如何使用SQL Query生成下表,其中CHEMISTRY,CA1,CA2,ExAM,TOT来自ChemTable,PHYSICS,CA1,CA2,ExAM,TOT,来自PhyTable和ENGLISH,CA1,CA2,ExAM, TOT来自EngTable。感谢
__________________________________________________________________________
| CHEMISTRY | PHYSICS | ENGLISH |
|________________________|________________________|________________________|
| CA1 | CA2 | EXAM | TOT | CA1 | CA2 | EXAM | TOT | CA1 | CA2 | EXAM | TOT |
|_____|_____|______|_____|_____|_____|______|_____|_____|_____|______|_____|
答案 0 :(得分:0)
您想要使用3种选择中的UNION:
SELECT "CHEMISTRY" as class,CA1,CA2, ExAM,TOT from Chemtable
UNION
SELECT "PHYSICS" as class,CA1,CA2, ExAM,TOT from PhyTable
UNION
SELECT "ENGLISH" as class,CA1,CA2, ExAM,TOT from EngTable
但实际上你想要规范你的表结构。