简体   繁体   English

比较两个表列

[英]Comparing two tables columns

O/p from this Report- Subject Report / Displays all the science subject from report Subject / O/p from this Report- Subject Report /显示来自报告主题的所有科学科目/

SELECT `Contact Email Address`,
       `Studentname`,
       `TypeofSubjectLine`
FROM   `Subject`
WHERE  `TypeofSubjectLine`IN ('Science, Maths')  

Student Report学生报告

SELECT `studentreport`.`Contact Email Address`,
       CASE WHEN `subject`.`Contact Email Address` IS NOT NULL THEN 'new registration' 
       ELSE 'No New Registration' END AS NewRegistraion
FROM   `subject` LEFT JOIN `studentreport` 
ON `subject`.`Contact Email Address`=`studentreport`.`Contact Email Address`

Student email address which exists in Report- studentreport, only map those students who has subjects in Science and Maths ONLY (subject report). Report- studentreport 中存在的学生电子邮件地址,仅映射那些只有科学和数学科目的学生(科目报告)。 If the students subject is Science & Maths then their email address match and they are -"not new registration", if their email address do not match then they are "new registration" Please tell me what is wrong in my query ?如果学生的科目是科学和数学,那么他们的电子邮件地址匹配并且他们是 -“不是新注册”,如果他们的电子邮件地址不匹配那么他们是“新注册” 请告诉我我的查询有什么问题?

SELECT `studentreport`.`Contact Email Address`,
       CASE WHEN `subject`.`Contact Email Address` IS NOT NULL 
            THEN 'new registration' 
       ELSE 'No New Registration' END AS NewRegistraion
FROM   `subject` LEFT JOIN `studentreport` 
    ON `subject`.`Contact Email Address`=`studentreport`.`Contact Email Address`
WHERE  `TypeofSubjectLine`IN ('Science', 'Maths')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM