select    `Contact Email Address`,
               `Contact First Name`
      FROM Test_1

    **Table B**

    select TableA.`Contact Email Address`,
  case when TableA.`Contact Email Address` IS NOT NULL THEN 'Match' 
  ELSE'No Match' 
  END as 'NA'
  from `Table A`
  left JOIN `Products` ON `Table A`.`Contact Email Address`='Products.`Contact Email Address`

Trying to get the two o/p into one single query

Select count(*)
  from Table A

    from 'TableB'
    where `NA`= 'No Match'
  • Can you be more specific about what you want from some sample input data. Your table B doesn't make much sense as there not filer or result from Products, the join criteria doesn't make a difference to the result as its a left join. – danblack Dec 16 '19 at 2:46

The following will given counts of matchs/non-matches:

select SUM(P.`Contact Email Address` IS NOT NULL) as 'Match',
       SUM(P.`Contact Email Address` IS NULL) as 'No Match,
from `Table A` A
left JOIN Products P
  ON USING (`Contact Email Address`)
group by P.`Contact Email Address`

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.