CREATE TABLE TableOne
([productIDs] varchar(13))
;
INSERT INTO TableOne
([productIDs])
VALUES
('1,10,3'),
('4,11,2'),
('5,8,1')
;
SELECT
productIDs
FROM
TableOne
WHERE
'1' IN (SELECT value FROM STRING_SPLIT(productIDs, ','));
|------------|
| 1,10,3 |
| 5,8,1 |
https://docs.microsoft.com/en-us/sql/t-sql/functions/string-split-transact-sql?view=sql-server-ver15','+cv.str_value+',' like '%,1,%'
here is an example:create table t(STR_VALUE varchar(20))
insert into t values ('1,2,3'),('10,11,12'),('4,3,1')
select * from t where ','+str_value+',' like '%,1,%'
/*
1,2,3
4,3,1
*/
if you mean just to return 1 record for such similarity, then just add the TOP clause into your select query, such as:
Open in new window