展开全部
先用左连接将1表完全查出,再用右连接将2表完全查出,最后合并结果
SELECT t1.id AS `编号`,t1.`name` AS `名称`,t1.score AS `科目一分数`,CASE WHEN t2.score IS NULL THEN 0 ELSE t2.score END AS `科目二分数`
FROM t1 LEFT JOIN t2 ON t1.id= t2.id
UNION
SELECT t2.id AS `编号`,t2.`name` AS `名称`,CASE WHEN t1.score IS NULL THEN 0 ELSE t1.score END AS `科目一分数`,t2.score AS `科目二分数`
FROM t1 RIGHT JOIN t2 ON t1.id= t2.id;
更多追问追答
追问
不好意思,如果还有一张表是科目三的学分,三张表(或更多张表)要整合到一起怎么写?
追答
SELECT t.id,t.`name`,MAX(t.score1) AS `科目一成绩`,MAX(t.score2) AS `科目二成绩`,MAX(t.score3) AS `科目三成绩`
FROM (SELECT id,`name`,score AS `score1`,0 AS `score2`,0 AS `score3` FROM t1
UNION ALL
SELECT id,`name`,0 AS `score1`,score AS `score2`,0 AS `score3` FROM t2
UNION ALL
SELECT id,`name`,0 AS `score1`,0 AS `score2`,score AS `score3` FROM t3) t
GROUP BY t.id;
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
呵呵。没有任何信息。就很难办了。应该找出用户的信息。以及是如何导出的。
或者strings 这个文件 看看有没有有用的信息
或者strings 这个文件 看看有没有有用的信息
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询