查询表达式

时间:2017-09-29 11:31:00

标签: sql ms-access

我在学校项目中使用ms-access,我需要从两个表中获取数据。

我试着做这个SQL查询:

SELECT m.MessageID, m.MessageSubject, m.MessageContent, m.MessageIsRead, 
    m.MessageSendDate, m.MessageDeletedBy,
    s.UserFisrtName + '' + s.UserLastName AS Sender,
    r.UserFisrtName + '' + r.UserLastName AS Reciver
FROM Messages m
INNER JOIN Users AS s ON s.UserID = m.MessageSenderID
INNER JOIN Users AS r ON r.UserID = m.MessageReciverID

我收到错误:

Syntax error (missing operator) in query expression 's.UserID = m.MessageSenderID INNER JOIN Users AS r ON r.UserID = m.MessageReciverI'

我已经遇到此问题的问题Here

有什么建议吗?

1 个答案:

答案 0 :(得分:1)

您的代码看起来不像MS Access。我希望:

       (s.UserFisrtName & " " & s.UserLastName) AS Sender,

没有理由在两个名字之间放一个空字符串。例如,如果你想放一个空格,那么它看起来像是:

// SEARCHES FOR SHARING CODE IN DATABASE (ONLINE)
let parentRef = Database.database().reference().child("Recipes")

parentRef.observeSingleEvent(of: .value, with: { snapshot in

    // SHOWING WHATEVER WAS RECEIVED FROM THE SERVER JUST AS A CONFIRMATION. FEEL FREE TO DELETE THIS LINE.
    print(snapshot)

    // PROCESSES VALUES RECEIVED FROM SERVER
    if ( snapshot.value is NSNull ) {

       // DATA WAS NOT FOUND
       print("– – – Data was not found – – –")

    } else {

        // DATA WAS FOUND
        for user_child in (snapshot.children) {

            let user_snap = user_child as! DataSnapshot
            let dict = user_snap.value as! [String: String?]

            // DEFINE VARIABLES FOR LABELS
            let recipeName = dict["Name"] as? String
            let recipeDescription = dict["Description"] as? String
            print("– – – Data for the recipe \(recipeName) with the description \(recipeDescription) was found successfully! – – –")
        }
    }
}