[英]How to do a inner join with like condition in sql
Basically i have two tables and the two tables are EmployeeDetails and SalaryStatement are described below.基本上我有两个表,这两个表是 EmployeeDetails 和 SalaryStatement,如下所述。
EmployeeDetails table:-员工详细信息表:-
SalaryStatement table:- SalaryStatement 表:-
I need to use the Employee_name field from EmployeeDetails table and see whether it is used in Operations field from SalaryStatement table.我需要使用 EmployeeDetails 表中的 Employee_name 字段,并查看它是否用于 SalaryStatement 表中的 Operations 字段。 If the string "Name1" matches i need to do inner join from table1 and table2 considering all attributes from two tables.如果字符串“Name1”匹配,我需要考虑两个表的所有属性,从 table1 和 table2 进行内连接。 I am not sure how to use LIKE condition in inner join.我不确定如何在内部连接中使用 LIKE 条件。 Table 1 EmployeeDetails table is the base table here.表 1 EmployeeDetails 表是这里的基表。
If you want the employee's name contained inside Operations
then do this:如果您希望员工的姓名包含在Operations
中,请执行以下操作:
select *
from EmployeeDetails e inner join SalaryStatement s
on s.Operations like concat('%', e.EmployeeName, '%')
or maybe:或者可能:
select *
from EmployeeDetails e inner join SalaryStatement s
on s.Operations like concat('%(', e.EmployeeName, ' ==%)%')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.