简体   繁体   English

如何使用列名中的空格进行SOQL查询?

[英]How do I make an SOQL Query with Spaces in Column Names?

I'm trying to make an SOQL query using the simple_salesforce python package. 我正在尝试使用simple_salesforce python软件包进行SOQL查询。 I'm having a bit of trouble querying columns which have spaces in the column names: 查询列名中包含空格的列时遇到一些麻烦:

sf.query_all("SELECT Id, Name, Email FROM Lead WHERE `Lead Source`=Calculator (Website)")

I'm trying to use the conventional SQL syntax of dealing with pesky column names (I have also tried [] brackets) but I keep getting a SalesforceMalformedRequest . 我正在尝试使用处理讨厌的列名的常规SQL语法(我也尝试过[]括号),但是我一直在获取SalesforceMalformedRequest

I want to get a python dict which contains the IDs, Names and Emails of any leads that have a lead source of 'Calculator (Website)'. 我想获取一个python字典,其中包含潜在客户来源为“计算器(网站)”的所有潜在客户的ID,名称和电子邮件。

I don't have privileges to change the column names, so any help on how to query, or how to access the column names in some other way, would be a lot of help! 我没有更改列名的特权,因此任何有关如何查询或如何以其他方式访问列名的帮助都将为您提供很多帮助!

As @user2864740 mentioned in the comments above, Salesforce doesn't allow spaces in field api names. 如上述评论中的@ user2864740所述,Salesforce不允许在字段api名称中使用空格。 In this situation, assuming you are trying to query the standard field with the English label of "Lead Source", the api name is LeadSource 在这种情况下,假设您要查询带有“ Lead Source”英文标签的标准字段,则api名称为LeadSource

在此处输入图片说明

You would want your query to be: 您希望查询为:

sf.query_all("SELECT Id, Name, Email FROM Lead WHERE LeadSource = 'Calculator (Website)'")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM