[英]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.