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)
 Help with a query !

Author  Topic 

sqlilliterate
Starting Member

40 Posts

Posted - 2008-09-26 : 03:26:34
help me in writing a query...

I need to find the particular values from the below list which contains the numbers --> 10, 20, 30

My column values...
Production Supervisor - WC10
Production Supervisor - WC20
Production Supervisor - WC30
Production Supervisor - WC40
Production Supervisor - WC45
Production Supervisor - WC50
Production Supervisor - WC60
Production Technician - WC10
Production Technician - WC20
Production Technician - WC30
Production Technician - WC40
Production Technician - WC45
Production Technician - WC50
Production Technician - WC60

But my like condn values (i.e. 10,20,30) comes as a result set from another table.

help me with a query like this...
(this qry won't work since the subquery results more than 1 row)

select * from <table> where <column> like
(select no from <table2>)


Thanks in advance...









visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-26 : 03:28:56
may be this
select t.* from <table> t
inner join <table2> t2
on t.<column> like '%' + t2.no + '%'
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-09-26 : 03:30:47
select t1.* from table1 as t1 inner join table2 as t2 on t1.col like '%'+t2.no


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-09-26 : 03:31:40


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sqlilliterate
Starting Member

40 Posts

Posted - 2008-09-26 : 06:21:19
Thanks v much Vishak n madhi...

It worked :)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-26 : 06:22:25
quote:
Originally posted by sqlilliterate

Thanks v much Vishak n madhi...

It worked :)


you're welcome
Go to Top of Page
   

- Advertisement -