0

选择数据库行值是否与一组字符串匹配的有效方法

  SELECT id FROM tablename where 
    LeadStatus like "%Contact Attempt 1%" or 
    LeadStatus like "%Contact Attempt 2%" or 
    LeadStatus like "%Contact Attempt 3%" or 
    LeadStatus like "%Contact Attempt 4%" or 
    LeadStatus like "%Contact Attempt 5%" or 
    LeadStatus like "%Contact Attempt 6%" or 
    LeadStatus like "%Contact Attempt 7%" or 
    LeadStatus like "%Call Back/Follow-up%" or 
    LeadStatus like "%Working%" or 
    LeadStatus like "%Credit Pulled%" or 
    LeadStatus like "%Selected other Lender%" or 
    LeadStatus like "%Pre-Approved%" or 
    LeadStatus like "%Application Taken/Sent%" or 
    LeadStatus like "%Application Received%" or 
    LeadStatus like "%Submitted%" or 
    LeadStatus like "%Funded%" or 
    LeadStatus like "%Future Opportunity%" or 
    LeadStatus like "%Manager Review%"

我觉得很清楚我想要什么?

注意:我无法更改该LeadStatus值,因为它是从不受我控制的 API 中获取的

4

1 回答 1

2

使用IN运算符怎么样?

这是SQLFiddle.com上的一个示例。

您可以动态构建 CSV 字符串列表,只需将其插入括号之间即可。但是,使用 IN 运算符的唯一缺点是您不能应用通配符搜索(使用“%”)。

于 2012-11-07T14:51:48.107 回答