表A包括firstname,secondname,lastname,msisdn,registrationdate ..表b具有firstname,secondname,lastname,msisdn,registrationdate和其他一些列 – 但我只想考虑这些提到的5列.
我有这样的东西
SELECT SELECT A.MSISDN,A.FIRSTNAME,A.SECONDNAME,A.LASTNAME,A.REGDATE, B.MSISDN,B.FIRSTNAME,B.SECONDNAME,B.LASTNAME,B.REGDATE
FROM TABLE1 A
INNER JOIN TABLE2 B ON A.MSISDN = B.MSISDN
WHERE A.FIRSTNAME != B.FIRSTNAME
OR A.LASTNAME != B.LASTNAME
以前我只是从表A中考虑了名字,姓氏,并检查了表B中的不匹配,但是我收到成千上万的记录作为结果,我想缩小搜索范围.
我如何在这里包括一个if else case
if a.firstname == b.firstname && a.secondname == b.lastname - Ignore this record.
if a.firstname == b.firstname && a.lastname == b.lastname - Ignore this record.
if a.firstname == b.firstname && a.lastname == b.secondname- Ignore this record.
if a.firstname not equal to b.firstname - show this record as result
if a.firstname == b.firstname && a.secondname not equal to b.lastname - show this record as result
否则将所有记录显示为不属于上述任何一种情况的结果.另外如果可能的话,请包括一个解决方案来忽略大写字母和小写字母,同时检查不匹配.
这里的问题是,在执行@sagi中的查询后,在结果中,我得到的是具有第一,第二和最后一个名称完美匹配的行,但是具有不同的注册日期 – 因为我们不考虑查询中的注册日期,会影响结果吗?