问题描述
有两张桌子.表 a 和 b.A 包含 msisdn、firstname、secondname、lastname、regdate(注册数据).表 b 也有相同的字段.我想比较这两个表,msisdn 的名字和姓氏字段.如果表 A 中的 msisdn X 的名字为 jim,姓氏为 halpert,并且相同的 msisdn X 在表 B 中的名字为 michael,第二个名称为 scott,我需要将这些类型的 msisdn 作为我的查询结果.在两个表和不同名称中具有相同 msisdn 的那个.如果其中任何一个名称(名字或姓氏)不匹配,则应显示为结果.
There are 2 tables. Table a and b. A contains msisdn, firstname, secondname, lastname, regdate(registration data). Table b also has the same fields. I want to compare these two tables, the msisdn's, firstname and lastname fields. If msisdn X in table A has firstname as jim and lastname as halpert, and the same msisdn X has firstname as michael and secondname as scott in table B, i need to get these kinds of msisdn's as my query result. the one's with same msisdn in both tables and different names. if either of these names(first or last) mismatches, that should be shown as result.
如果我没有准确解释场景,我很抱歉.我希望有人理解并回答这个问题.
I'm sorry if i did not explain the scenario accurately. I hope someone understands and answers this.
谢谢:)
推荐答案
SELECT A.*, B.*
FROM TABLEA A
INNER JOIN TABLEB B ON A.MSISDN = B.MSIDN
WHERE A.firstname != B.firstname
OR A.lastname != B.Lastname
这篇关于SQL如何比较两个表中的数据并得到两个表之间不同的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!