0

I try to get select with code below

Select `admin`.`admin_id`, `admin`.`email` AS `admin_email`, IF(customer.email IS NOT NULL OR admin_email IS NOT NULL, 'Subscribed', 'Unsubscribed') AS `field_name`, (...Something else) from admin, customer, (...Something else);

Then get error #1054 - Unknown column 'admin_email' in 'field list'

1 Answers1

0

You can not use alias in the if statement, so

Select admin.admin_id, admin.email AS admin_email, IF(customer.email IS NOT NULL OR admin.email IS NOT NULL, 'Subscribed', 'Unsubscribed') AS field_name, (...Something else) from admin, customer, (...Something else);

yusher
  • 226
  • 1
  • 5