jeudi 24 décembre 2015

mysql: inner query is not working inside selectif statement

I want result for below query be Y if Email is blacklisted, else run the inner query and return the specific facility Name.

Select if (EmailBlacklisted = 'Y', 'Y', 
     'select a.facilityname from facility a
     inner join domainfacility b on a.facility_ID=b.facility_facility_ID
      inner join domain c on b.domain_Domain_ID = c.Domain_ID 
     where a.facilitystatus="A" and c.DomainName = "cd.com" ') 
from domain where DomainName= 'cd.com';

BUT query returning same inner query as RESULT if emailBlacklisted is N in Domain table. please help

Aucun commentaire:

Enregistrer un commentaire