计数返回double值

时间:2014-12-18 12:13:53

标签: mysql

我们有小型拍卖系统,我添加了为项目(param的名称及其值)编写一些可选参数的选项。问题是当有一些参数 COUNT(*)AS bid_count 返回double值时。问题出现在 auction_params GROUP_CONCAT 功能中,但我无法弄清楚。

SELECT a.*, u.user_nick, u.rating_positive, u.rating_negative, u.money_back, u.user_city, u.user_zip, u.user_country
    ,GROUP_CONCAT(DISTINCT ap.param_name SEPARATOR '$concatSeparator') AS param_names
    ,GROUP_CONCAT(DISTINCT ap.param_value SEPARATOR '$concatSeparator') AS param_values
    ,COUNT(*) AS bids_count, MAX(b.bid) AS last_bid
    ,(SELECT i.increment
        FROM increments i
        WHERE i.min_price <= IFNULL(MAX(b.bid), 0) AND i.currency = a.currency
        ORDER BY i.min_price DESC
        LIMIT 1)
        AS min_bid
    ,(SELECT u.user_nick
        FROM users u
        WHERE u.user_id = (SELECT user_id FROM bids WHERE auction_id = a.auction_id AND bid = MAX(b.bid))
        LIMIT 1)
        AS last_bid_user_nick
FROM auctions a
LEFT JOIN users u ON u.user_id = a.user_id
LEFT JOIN auctions_params ap ON ap.auction_id = a.auction_id
LEFT JOIN bids b ON b.auction_id = a.auction_id
WHERE a.auction_id = $auctionID
LIMIT 1

感谢您的帮助和对不起的英语

0 个答案:

没有答案