【问题标题】:What is the code to search using partial text entered in a text box?使用在文本框中输入的部分文本进行搜索的代码是什么?
【发布时间】:2016-05-05 20:44:20
【问题描述】:

这对吗?

Select [A], [B], [C] From [Database] Where [A] Like @TextBox1%

【问题讨论】:

    标签: sql search text partial


    【解决方案1】:

    正确的是:

    Select field1, field2, ... From table Where fieldx like '%whatever%';
    
    • %whatever%' => 字段中的任何位置
    • 'whatever%' => 字段开头
    • '%whatever' => 在字段末尾

    【讨论】:

    • 您对whatever%%whatever 的解释是倒退的。 whatever% 正在寻找以whatever 开头的字符串,%whatever 正在寻找以whatever 结尾的字符串。
    • 我正在尝试从我拥有的加拿大数据库中提取数据。如果客户在我的文本框中输入A0K,则该列中有很多A0K,例如A0K 1A0,A0K 1B0等...
    • 从 [PostalCode] WHERE ([PostalCode] LIKE '%@PostalCode%') 中选择 [Province]、[Zone]、[Degree]、[UValueMetric]、[UValueEnglish]、[EnergyRating]
    • 你把这个 sql 放在哪里?以及为什么要添加 @ 和 ( ) ?
    • 这是 asp 页面,@PostalCode 是文本框名称。
    猜你喜欢
    • 1970-01-01
    • 2019-06-03
    • 1970-01-01
    • 2013-03-31
    • 1970-01-01
    • 2021-02-03
    • 2020-12-24
    • 2013-07-12
    • 1970-01-01
    相关资源
    最近更新 更多