mysql - SQL How to add if else conditions in sql -


table consists of firstname, secondname, lastname, msisdn, registrationdate.. table b have firstname, secondname, lastname, msisdn, registrationdate , few other columns - want consider these mentioned 5 columns. have this

select select a.msisdn,a.firstname,a.secondname,a.lastname,a.regdate, b.msisdn,b.firstname,b.secondname,b.lastname,b.regdate  table1 inner join table2 b on a.msisdn = b.msisdn a.firstname != b.firstname  or a.lastname != b.lastname 

previously considered firstname, lastname table , checked mismatch in table b, i'm getting thousands of records results , wanted narrow down search.

how include if else case here

if a.firstname == b.firstname && a.secondname == b.lastname - ignore record.  if a.firstname == b.firstname && a.lastname == b.lastname - ignore record.  if a.firstname == b.firstname && a.lastname == b.secondname- ignore record.  if a.firstname not equal b.firstname - show record result  if a.firstname == b.firstname && a.secondname not equal b.lastname - show record result 

else show records results doesn't fall of these above cases. if possible, please include solution ignore capital letters , small letters while checking mismatches.

please find sample data here problem here is, after executing query @sagi, in results i'm getting rows has perfect match between first,second , lastnames has different registration date - not considering registration date in query, impact results?

this should trick :

select a.*, b.*  table1 inner join table2 b on a.msisdn = b.msisdn (upper(b.firstname),upper(b.lastname)) not in ((upper(a.firstname),upper(a.lastname)),(upper(a.firstname),upper(a.secondname))) 

no need if , if condition returns true, means conditions met, , either first_name different or last_name .


Comments

Popular posts from this blog

php - isset function not working properly -

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -