【问题标题】:How do I search for sub-items from a search query?如何从搜索查询中搜索子项?
【发布时间】:2018-10-25 01:59:48
【问题描述】:

假设我有一个'the black top hat the red shirt the blue top hat' 的搜索查询。项目'the black top hat''the red shirt' 存在于数组中,但'the blue top hat' 不存在于数组中。如果数组中存在这些项目,我将如何搜索,因为这些项目都组合成一个搜索字符串并且不是单独的。

我必须搜索'the', 'the black', 'the black top', ..., 'black', 'black top', etc...还是有更好的解决方案?

【问题讨论】:

    标签: database string algorithm array-algorithms


    【解决方案1】:

    试试看:

    select ...
    from ...
    where mycol like '%the black top hat%'
    and mycol like '%the red shirt%'
    —- etc
    

    过滤掉具有特定值的行:

    and mycol not like '%the blue top hat%'
    

    【讨论】:

    • 搜索是单个字符串,所以我不知道要拆分为“黑色礼帽”、“红色衬衫”和“蓝色礼帽”。
    • @siddha 这适用于单个字符串。你到底是什么意思?表中的数据示例和查询的变量搜索字符串究竟是什么?
    猜你喜欢
    • 2018-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多