雖然使用下面的查詢, 我得到的錯誤「#1054 - 未知列」在別名與查詢一起使用時出錯?
#1054 - Unknown column 'plus' in 'field list'
當使用
plus-minus
。否則,查詢運行良好。我想有些東西與我不知道如何使用別名有關。請指導!
謝謝。
查詢:
SELECT users.name,
count(*) as total,
SUM(sms.views)+ SUM(sms.downloads)+ (SELECT count(*) FROM `smsfb` WHERE (`feedback`=1 OR `feedback`=100) AND userid=users.uniqueID) AS plus,
SUM(sms.delreq)+(SELECT count(*) FROM `smsfb` WHERE (`feedback`=5 OR `feedback`=6) AND userid=users.uniqueID) AS minus,
plus-minus
FROM sms,users
WHERE sms.deviceID=users.uniqueID AND sms.catid!=23 AND sms.catid!=44 AND sms.catid!=45
AND date>="2011-10-03" AND date<"2011-10-09"
GROUP BY users.uniqueID HAVING total>10 ORDER BY total DESC LIMIT 0, 10
你能描述一下短信和用戶表嗎? –