Here's one way:declare @t table (ID int, Keyword varchar(10))insert @tselect 1, 'car' union allselect 1, 'boat' union allselect 1, 'van' union allselect 14, 'test' union allselect 14, 'car' union allselect 14, 'bike' union allselect 4, 'VAN' union allselect 5, 'scooter'declare @id intset @id = 1select idfrom @twhere keyword in ( select keyword from @t where id = @id )and id <> @idoutput:id-----------144
Be One with the OptimizerTG