mercredi 14 septembre 2016

SQL How to add if else conditions in sql

I have something like this

SELECT A.*, B.* 
FROM TABLE1 A
INNER JOIN TABLE2 B ON A.MSISDN = B.MSISDN
WHERE A.FIRSTNAME != B.FIRSTNAME 
OR A.LASTNAME != B.LASTNAME

How do i include an if else case here so that

if a.firstname == b.firstname && a.secondname == b.lastname - 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

else show all the records as results that doesn't fall into any of these above cases.

thank you..

Aucun commentaire:

Enregistrer un commentaire