我正在寫一個mysql查詢並出錯。MYSQL中IF條件的別名
「未知列‘逸’在‘字段列表’」由於發生在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 .. :)提前
感謝。
'where nCustomerID = nCustomerID'可能需要更正。 –