0
SELECT 
    C.CompanyId, 
    CompanyName, 
    Server, 
    ServerUsers, 
    ServerUptime, 
    ServerHostName, 
    ServerType 
FROM 
    CUSTOMERS AS C
INNER JOIN 
    USERS ON C.CompanyId = USERS.CompanyId
WHERE 
    USERS.UserEmail='matt' AND 
    USERS.UserPin='5153' AND 
    (SELECT Status FROM 4321_BlackBerryServices LIMIT 0,1)
LIMIT 0, 8

目前我的桌子在下面

        4321    T1 Solutions    EXCH-01 392 47 days, 17 min exch01.myCorp.com   ExchangeServices
        4321    T1 Solutions    EXCH-02 685 47 days, 17 min exch02.myCorp.com   ExchangeServices
        4321    T1 Solutions    Lync-01 368 47 days, 17 min lync01.myCorp.com   LyncServices
        4321    T1 Solutions    Lync-02 890 458 days, 58 min    lync02.myCorp.com   LyncServices

我想做的是添加 Status FROM 4321_BlackBerryServices 的最后一个结果,所以我想为我的表中的每个服务器添加最新状态

这怎么可能 ?

4

1 回答 1

0

如果我了解您的需求,请尝试以下操作:

SELECT 
    C.CompanyId, CompanyName, Server, ServerUsers, 
    ServerUptime, ServerHostName, ServerType, 
    (SELECT Status FROM 4321_BlackBerryServices 
     ORDER BY field_you_know DESC LIMIT 0,1) AS BBS_Status
FROM CUSTOMERS AS C
INNER JOIN USERS 
    ON C.CompanyId = USERS.CompanyId
   AND USERS.UserEmail = 'matt' 
   AND USERS.UserPin = '5153'
LIMIT 0, 8

在我的查询field_you_know字段中,您知道您可以对表格进行排序以获取最后一个。

于 2012-07-16T00:03:10.137 回答