[英]Outer query value is not able use in inner query
SELECT
(select Email from Contact where AccountId = Account.Id),
Id,
BillingCity,
BillingCountry,
BillingPostalCode,
BillingState,
BillingStreet,
Name,
Phone
FROM Account
where
LastModifiedDate < #[flowVars['timestamp']]
Problem here is I am not able to get the Email which is present in the sub query based on the Id of current iteration. 这里的问题是我无法基于当前迭代的ID获取子查询中存在的电子邮件。 Can you please help on this
你能帮忙吗
I'm not sure how you are running the query, and how you are accessing the result, but if you are doing it in a place that does not give you the result dynamically, meaning that you try to access the columns by expected name, ie trying to get the "email" column somehow, then you need to fix a small issue in the query. 我不确定您如何运行查询以及如何访问结果,但是如果您在无法动态获得结果的地方进行查询,则意味着您尝试按预期名称访问列,即尝试以某种方式获取“电子邮件”列,那么您需要修复查询中的一个小问题。
You need to add the AS
operator to give your subquery a meaningful name like email
like so: 您需要添加
AS
运算符,以便为子查询赋予一个有意义的名称,例如email
如下所示:
...
(select Email from Contact where AccountId = Account.Id) as email,
...
See fiddle here for working example: db-fiddle 有关工作示例,请参见此处的小提琴 : db-fiddle
You can get rid of the scalar sub-query and just put a join to the CONTACT table instead. 您可以摆脱标量子查询,而只需将联接放入CONTACT表中即可。 The following assumes that the CONTACT table is an optional relationship.
以下假定CONTACT表是可选关系。
SELECT
con.email,
acct.Id,
acct.BillingCity,
acct.BillingCountry,
acct.BillingPostalCode,
acct.BillingState,
acct.BillingStreet,
acct.Name,
acct.Phone
FROM account acct
LEFT OUTER JOIN
contact con ON con.account_id = acct.account_id
WHERE acct.LastModifiedDate < #[flowVars['timestamp']]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.