社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  DATABASE

在进行类似concat的比较时,mysql不返回结果

user2954295 • 6 年前 • 1369 次点击  

我正在MySQL中构建一个查询,以获取特定列的soundex与给定值的soundex类似的记录。

我正在提交此查询:

select nombre_busqueda, 
       soundex(nombre_busqueda), 
       soundex('derticia'), 
       concat('%', (soundex(nombre_busqueda)) , '%')  
from jugador j 
WHERE idjugador=472 

得到以下信息

nombre_busqueda
dertycia oscar alberto alvarez

soundex(nombre_busqueda)
D632641634162

soundex('derticia')
D632

concat('%', (soundex(nombre_busqueda)) , '%')
%D632641634162%

因此,进行比较并得到结果看起来是完美的。 但当我发出以下查询时:

select nombre_busqueda, 
       soundex(nombre_busqueda), 
       soundex('derticia'), 
       concat('%', (soundex(nombre_busqueda)) , '%')  
from jugador j WHERE 
soundex('derticia') like concat('%', (soundex(nombre_busqueda)) , '%')

什么都没有得到回报! 我做错了什么?在我看来,这很明显是可行的!

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/30474
 
1369 次点击  
文章 [ 1 ]  |  最新文章 6 年前
Madhur Bhaiya
Reply   •   1 楼
Madhur Bhaiya    6 年前

交换 LIKE :

select nombre_busqueda, 
       soundex(nombre_busqueda), 
       soundex('derticia'), 
       concat('%', (soundex(nombre_busqueda)) , '%')  
from jugador j 
WHERE soundex(nombre_busqueda) like concat('%', soundex('derticia') , '%')