简体   繁体   English

如何在两列不同的表中的字符串中查找公用名?

[英]How to find in a string a commun name in two columns, different tables?

Im building a program in c# that consist in import two differents excel files into tables in data base, similar to this: 我在c#中构建一个程序,该程序包含将两个不同的excel文件导入数据库的表中,类似于此:

First table[Details]: 第一表[详细信息]:

 Description                                Cost 
 Aeroport ticket by John                    200
 Emily Ticket to cinema                     200
 Aeroport ticket by Anna to the first class 500

Second Table[ClientInform]: 第二张表[ClientInform]:

CostumerName Cost
John         200
Emily        200
Anna         500

Result table: 结果表:

Description                               ClientName    Cost
Aeroport ticket by John                      John        200
Emily Ticket to cinema                       Emily       200
Aeroport ticket by Anna to the first class   Anna        500 

I have to display this on a gridview but if I have the right query I think I can do it in asp.net fairly easy.. I just don't know How to Seach in a string that can be random lenght, I was thinking in something similar to this: 我必须在gridview上显示此内容,但是如果我有正确的查询,我想我可以在asp.net中做到这一点非常简单。。与此类似:

select * from Details
full join ClientInform
on ClientInform.CostumerName= Details.Description
where Details.Description Like '%' +ClientInform.CostumerName+  '%'

something that Searche's similiar strings in both columns 两列中Searche的相似字符串

ps: the code in sql is just a demonstration ps:sql中的代码只是一个演示

Try something like this: 尝试这样的事情:

SELECT d.Description, c.CustomerName, c.Cost 
FROM Details d
INNER JOIN ClientInform c on d.Description Like '%' +c.CostumerName+  '%' AND c.COst = d.cost

Note : Like used on joining condition is sure kill the query performance. 注意: Like在联接条件上使用的那样肯定会杀死查询性能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当不同表中的两列具有相同名称时,如何使用SqlDataReader读取数据? - How to read data using SqlDataReader when two columns in different tables have same name? 如何按两个不同表的“名称”列排序 - How to sort by column “name” of two different tables 两个表之间的合并(由 IEnumerable 表示<ienumerable<string> &gt;) 具有不同的列</ienumerable<string> - Merge between two tables (represented by IEnumerable<IEnumerable<string>>) with different columns 比较两个不同表中的列 - comparing columns in two different tables 实体数据库优先:如何命名两个具有不同名称的表之间的两个不同关系 - Entity db first: how to name two different relationships between two tables with different names LINQ使用字符串列联接两个表 - LINQ joining two tables using string columns 如何从SQL Server中两个不同的表中获取两列的总数? - How to get the total count of two columns from two different tables in SQL Server? LINQ查找在两个单独的表中不同的记录 - LINQ find records that are different in two separate tables 如何在数据网格中显示来自联接表和表1的数据,并且两个具有相同名称的列 - how to display data in data grid that is from joined tables and table 1 and two have columns with the same name 如何在不同表的列表视图列中显示 - How to display in listview columns from different tables
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM