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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-03-11 : 10:54:37
|
| Andy writes "I have two tables, one is a list of strets and the other is a list of full addresses, comma delimited in a text field.I want to know for each street name [table 1] how many addresses have a similar ( % like % ) existence. I want a list of [table 1] list of streets, with a SUM of how many existences of it are found in the other table.Please can you helpAndy" |
|
|
lfmn
Posting Yak Master
141 Posts |
Posted - 2002-03-11 : 11:14:30
|
| how about:create table #tablea(address varchar(60))create table #tableb (streetname varchar(60))insert into #tablea values('cookie street')insert into #tablea values('cake street')insert into #tablea values('pie street')insert into #tablea values('cookie2 street')insert into #tableb values('cookie')insert into #tableb values('pie')select count(streetname), streetnamefrom #tableb b, #tablea awhere CHARINDEX(streetname, address) > 0group by streetnameSQL is useful if you don't know cursors :-) |
 |
|
|
|
|
|