我试着用下面的代码选择
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);
然后获取错误 #1054 - Unknown column 'admin_email' in 'field list'
1条答案
按热度按时间sulc1iza1#
不能在if语句中使用别名,因此
选择
admin
.admin_id
,admin
.email
作为admin_email
,如果(customer.email不为null或admin.email不为null,'subscribed'、'unsubscribed')为field_name
,(…其他)来自管理员,客户,(…其他);