0

我试图从我的桌子上获得花费的时间。有用。但现在我想将其限制为一个用户组。所以我做了这个:

SELECT
    s.shortname AS servername, s.displaycolor AS displaycolor,
    MIN(
        if(`yearweek`=yearweek(CURRENT_DATE(),3) AND (s.admin_group=u.usergroupid OR find_in_set(s.admin_group, u.membergroupids)>0),
            (SELECT COUNT(*)
            FROM godziny_tygodnie AS x
                LEFT JOIN vbulletin.vb_user AS xu ON xu.userid=x.dbid
            WHERE gw.sid=x.sid
            AND x.`yearweek`=gw.`yearweek` AND x.`time` > gw.`time`)+1
            AND ( xu.usergroupid=s.admin_group OR find_in_set(s.admin_group, xu.membergroupids)>0)
        , NULL)
    ) AS rweek0,
    -- there are more columns simillar to previous, but with different time interval
FROM godziny_tygodnie gw
    INNER JOIN godziny_miesiace gm ON gw.dbid=gm.dbid AND gw.sid=gm.sid
    INNER JOIN godziny_lacznie gt ON gw.dbid=gt.dbid AND gw.sid=gt.sid
    LEFT JOIN serwery AS s ON s.id=gw.sid
    LEFT JOIN vbulletin.vb_user u ON u.userid=gw.dbid
WHERE gw.dbid=:uid
GROUP BY gw.dbid, gw.sid

它给了我错误Column not found: 1054 Unknown column 'xu.usergroupid' in 'field list'

为什么不能执行?vbulletin.vb_user.usergroupid存在...

4

1 回答 1

0

问题是括号错误。9. 行的)+1from end 应该在 10 行的末尾。现在一切正常:)

于 2013-05-14T18:45:01.430 回答