首页 / MYSQL / 别名不在MYSQL中处理IF条件
别名不在MYSQL中处理IF条件
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了别名不在MYSQL中处理IF条件,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含898字,纯文字阅读大概需要2分钟。
内容图文
![别名不在MYSQL中处理IF条件](/upload/InfoBanner/zyjiaocheng/892/40f3c0e6b3e8427d919da53110eca9be.jpg)
我正在编写一个mysql查询并收到错误.
“Unknown column ‘dat’ in ‘field list'”
由于在mysql的IF条件中使用别名而发生此错误.
这是mysql查询:
SELECT
nCustomerID,
dDateRegistered,
(select count(nPlayerID) from credit_logs
where nPlayerID=nCustomerID) as total_clog,
(select count(nPlayerID) FROM bl_transaction_history
where nPlayerID=nCustomerID) as total_tran,
(select count(nCustomerID) from customer_freeplays
where nCustomerID=nCustomerID) as total_free,
(select dDateAdded from bl_transaction_history
where nPlayerID=nCustomerID) as dat,
(select DATEDIFF(now(),dat)/30 ) as date_differece1,
(select DATEDIFF(now(),dDateRegistered)/30 ) as date_difference2,
IF (dat IS NOT NULL,(select DATEDIFF(now(),dat)/30 ),
(select DATEDIFF(now(),dDateRegistered)/30 )) as date_difference
FROM bl_customers
WHERE nAccountStatus=1
and bDeleted=0
having total_clog>0
or total_tran>0
or total_free>0
任何帮助都会被appriciated ..
内容总结
以上是互联网集市为您收集整理的别名不在MYSQL中处理IF条件全部内容,希望文章能够帮你解决别名不在MYSQL中处理IF条件所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。
来源:【匿名】