Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
lichette
Starting Member
3 Posts |
Posted - 2009-10-09 : 21:10:22
|
Hi,I'm new on this forum and quite new with SQL coding too, so thanks for your help and your kind understanding of my "ignorance".I am trying to link table 1 (1 column called client_name) to table 2 (1 column called advertiser_name) where table 2 contains a list of 5000 terms that could (or could not) be embedded into any of the client_names in table 1.Here is an exampleTable1Client_name:Walt Disney CorporationEbay Inc.com Amazon accountTable2Advertiser_name:AmazonDisneyEbayThe output i need is a 3rd table that would look like thisClient_Name Advertiser_NameWalt Disney Corporation DisneyEbay Inc Ebay.com Amazon account AmazonLike %table2.advertiser_Name% would have been great but it seems the like operator only works with a constant.Is there any solution to resolve this problem.THANK you SO MUCH for your help. I much appreciate it!Julie  |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-10-09 : 22:16:33
|
Try this:select t1.Client_name ,t2.Advertiser_namefrom table2 t2inner join table1 t1 on t1.Client_name like '%' + t2.Advertiser_name + '%' Be One with the OptimizerTG |
 |
|
|
lichette
Starting Member
3 Posts |
Posted - 2009-10-10 : 14:42:59
|
| Thanks TG but it did not work. I got the following error messages:ERROR: Expression using addition (+) requires numeric types.ERROR: LIKE operator requires character operandsIs there another way to achieve this, since your proposed solution unfortunately did not work?Thanks again for your suggestion.Julie |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-10-10 : 17:13:26
|
| Please post the code that you tried as well as the sql datatypes of the columns involved.Be One with the OptimizerTG |
 |
|
|
lichette
Starting Member
3 Posts |
Posted - 2009-10-10 : 17:18:54
|
| here is the code i tried (I'm using SAS not mySQL therefore the proc sql statement):proc sql;Create table temp asselect t1.Company_name ,t2.Advertiserfrom SSP.SSPClients as t2inner join SSP.Datamart as t1 on t1.Company_name like '%' + t2.Advertiser + '%';quit;Company_name and Advertiser are both text fields (length of $44 and $36)Thanks again! |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-10-10 : 17:28:08
|
| Oh - sorry to waste your time, Julie. This forum is specific to MS Sql Server. I think you'll have to find a SAS forum...Be One with the OptimizerTG |
 |
|
|
|
|
|