我有下面的 sql,如果我取出表的内部连接并对值进行硬编码,我会得到 2 条记录。但是当我使用内部连接语句时,我只得到 1 条记录。我知道对于 MYSQL,like 子句不区分大小写。这是下面的sql。我不知道为什么它只返回行。
SELECT
a.project_code as projectCode,
a.project_name as projectName,
a.project_creation_date as projectCreationDate,
a.project_end_date as projectEndDate,
a.project_status as projectStatus
from projects a
inner join tmp_rec_naren8 b
on a.project_name like concat("%",b.expertise_desc,"%")
OR a.project_description like concat("%",b.expertise_desc,"%") ;
如果我将以上内容更改为:
select *
from projects
where project_name like '%java%'
OR project_description like '%java%';
我得到 2 行而不是 1 行。
表tmp_rec_naren8
只有一列expertise_desc
并包含以下数据:
expertise_desc
--------------
XML
Python
DWH
Java
表projects
有很多列:.. 但下面这些是相关的
project_code sr_user_name project_name project_descriiption ..
-----------------------------------------------------------
1 naren5 POS C++, XML,Java
2 naren7 INV Networking
3 naren9 CCV Java, Unix
第一个查询返回 1 行:
project_code sr_user_name project_name project_descriiption ..
---------------------------------------------------------------
1 naren5 POS C++,XML,Java
第二个查询返回 2 行
project_code sr_user_name project_name project_descriiption ..
-----------------------------------------------------------
1 naren5 POS C++, XML,Java
3 naren9 CCV Java, Unix