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)
 preforl LIKE on a list of results

Author  Topic 

wbcintsol
Starting Member

4 Posts

Posted - 2008-08-24 : 20:32:53
Hi,
I'm trying to do the following:
I have a column in a table that is a comma seperated values for a search criteria on another table.
I've created a split function that selects that column and seperates it into a list.
I now need to query the other table and select from a column all the items that are LIKE each of the list in the results from the split.
How would you do that?
Thanks,
Keren

My query looks as follows:

SELECT * from tbl_RTGS_OSBSB
WHERE
Payment_Details in ***** PROBLEM IS HERE **** (
select String from Split(
(
SELECT Product_Details.MultyLineField1
FROM
Product_Details,
Sub_Customer_To_Products
where
Sub_Customer_To_Products.Product_Detail_Id = Product_Details.Product_Detail_Id AND
Product_Type_Id = @ProductType AND
Sub_Customer_Id = @SubCustomer
)
, ','))


visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-25 : 00:04:58
cant you just use like this?

SELECT *
FROM tbl_RTGS_OSBSB t1
INNER JOIN Sub_Customer_To_Products t2
ON ','+ CAST(t1.Product_Detail_Id AS varchar(50))+',' LIKE '%,'+CAST(t2.Product_Detail_Id AS varchar(50))+',%'
Go to Top of Page
   

- Advertisement -