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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 search for table 1 values in table 2

Author  Topic 

sachingovekar
Posting Yak Master

101 Posts

Posted - 2011-09-29 : 08:19:46
create table #table1
( title6 varchar(100), cnt int)

insert into #table1 values ('abc',2)
insert into #table1 values ('efg',4)

create table #table2
( title6 varchar(100),
title7 varchar(100),
title8 varchar(100),
title9 varchar(100),
title10 varchar(100),
title11 varchar(100)
)

insert into #table2 values ('qwe','abc','efg','hyu','xyz','wer',1)
insert into #table2 values ('ilm','abc','efg','hyu','xyz','wer',1)
insert into #table2 values ('efg','wer','abc','hyu','xyz','wer',1)
insert into #table2 values ('cvb','efg','efg','hyu','xyz','wer',1)
insert into #table2 values ('asd','fgh','efg','hyu','xyz','wer',1)
insert into #table2 values ('wer','qwe','dfg','efg','xyz','wer',1)
insert into #table2 values ('wer','qwe','dfg','sdz','efg','wer',1)

I want to search one value at a time :
for eg: "abc" from table 1 will be search from title6 to title 11 in table 2

the condition is "abc" should be stopped searching when we find 2 rows for abc in table 2 because the count of "abc" is 2 in table 1

Imp: once we have found the text "abc" in any row, that row should not be counted again for any other string, it has to be excluded from the search

please help

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-29 : 08:32:49
you can use quirky update method for this

see

http://visakhm.blogspot.com/2010/03/using-quirky-updates-to-develop-well.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sachingovekar
Posting Yak Master

101 Posts

Posted - 2011-09-29 : 08:44:23
Kindly please provide some other example as the link is not similar to my above request.
Go to Top of Page

namman
Constraint Violating Yak Guru

285 Posts

Posted - 2011-09-29 : 12:07:05
What is the expected output based on your example data?
Go to Top of Page
   

- Advertisement -