Is it possible to use as with the word ALL

Say I have the following:

declare @A table (a int)

insert into @A
select 1 union all
select 2 union all
select 3

select a FROM @A 
where a > ALL (select 1 union all select 2)

That will work. But I need to use Like instead of more than here,

declare @A table (a int)

insert into @A
select 1 union all
select 2 union all
select 3

select a FROM @A 
where a LIKE ALL (select 1 union all select 2)

Please help me.

Edit : This is what my original old table looks like,

declare @A table (a varchar(500))

insert into @A
select 'a;b;c' union all
select 'a;d;b' union all
select 'c;a;e'

My application sends the values ​​in my SP as' a; b 'or' b; c; a ', etc.,

Now I need to select only those rows in the @A table that have a and b or b and c and a. I use the split function in my SP to make user input as a table. That is why I need to use like EVERYTHING here. But any other suggestion is also welcome.

+3
source share
3 answers

. , - .

declare @T table (ID int primary key, Col varchar(25))

insert into @T
select 1, 'a;b;c' union all
select 2, 'a;b;c' union all
select 3, 'a;d;b' union all
select 4, 'bb;a;e'

declare @Input table(val varchar(10))
insert into @Input values('a')
insert into @Input values('b')

select T.ID
from @T as T
  inner join @Input as I
    on ';'+T.Col+';' like '%;'+I.val+';%'
group by T.ID    
having count(t.ID) = (select count(*) from @Input)

ID
1
2
3
+2

IN?

 SELECT a FROM @A WHERE a IN (1,2)
0

Try creating a new table that will have search values, and then join it using the LIKE statement.

create table searchvalues

(

myvalues varchar(30)

)

INSERT INTO SearchValues    
SELECT '%1%'   
UNION SELECT '%2%'


SELECT * FROM @A    
join searchvalues on a like myvalues
0
source

All Articles