gpt4 book ai didi

mysql - 我如何选择喜欢mysql中的通配符

转载 作者:行者123 更新时间:2023-11-29 05:48:09 25 4
gpt4 key购买 nike

我有一个表,其中包含列名并已存储

|name|

Lebron James C. Durant

我想选择和过滤不完整的名字。但结果为空。

SELECT * from partners where name LIKE "%Lebron James Durant%" 

这是我在此查询中的预期结果。

|name|

Lebron James C. Durant

最佳答案

% 符号替换空格。

SELECT * from partners where name LIKE '%Lebron%James%Durant%';

如果你想查询一个任意字符串,像这样使用(@n 可能是你的查询参数):

SET @n = 'Lebron James Durant';
SELECT * from partners where name LIKE CONCAT('%', REPLACE(@n, ' ', '%'), '%')

关于mysql - 我如何选择喜欢mysql中的通配符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57490258/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com