Salesforce - 仅允许在 Apex 代码中绑定变量 - MALFORMED_QUERY
Salesforce - Bind variables only allowed in Apex code - MALFORMED_QUERY
我需要与此 SQL 查询等效的 SOQL 查询:
SQL查询:
SELECT id, username, (SELECT username FROM users where id = u.manager_id) as manager_username
FROM users u
我试过了
SELECT Id, Username, (SELECT Username FROM User WHERE Id=usr.ManagerId) FROM User usr
我不断得到的是
[
{
"message": "\n(SELECT Username FROM User WHERE Id=usr.ManagerId) FROM User usr WHERE\n
^\nERROR at Row:1:Column:57\nBind variables only allowed in Apex code",
"errorCode": "MALFORMED_QUERY"
}
]
有什么建议吗?
SOQL 不支持字段比较。但在你的情况下,它不是必需的。经理是父记录,因此可以通过点表示法访问其字段。您的查询可以是:
SELECT Id, Username, Manager.Id, Manager.Username FROM User
我需要与此 SQL 查询等效的 SOQL 查询:
SQL查询:
SELECT id, username, (SELECT username FROM users where id = u.manager_id) as manager_username
FROM users u
我试过了
SELECT Id, Username, (SELECT Username FROM User WHERE Id=usr.ManagerId) FROM User usr
我不断得到的是
[
{
"message": "\n(SELECT Username FROM User WHERE Id=usr.ManagerId) FROM User usr WHERE\n
^\nERROR at Row:1:Column:57\nBind variables only allowed in Apex code",
"errorCode": "MALFORMED_QUERY"
}
]
有什么建议吗?
SOQL 不支持字段比较。但在你的情况下,它不是必需的。经理是父记录,因此可以通过点表示法访问其字段。您的查询可以是:
SELECT Id, Username, Manager.Id, Manager.Username FROM User