By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table yourtable (name varchar(100));
insert into yourtable values ('Road');
insert into yourtable values ('Bike');
insert into yourtable values ('Test');
insert into yourtable values ('Another Text');
insert into yourtable values ('Hello World');
insert into yourtable values (NULL);
insert into yourtable values ('RoadBike');
insert into yourtable values ('BikeRoad');
insert into yourtable values ('Nothing');
insert into yourtable values ('0815');
insert into yourtable values ('Road1');
insert into yourtable values ('1BikeRoady');
12 rows affected
WITH searchitems AS
(SELECT 'Road' AS item
UNION ALL
SELECT 'Bike')
SELECT DISTINCT y.name
FROM yourtable y
JOIN searchitems s
ON y.name LIKE CONCAT('%',s.item,'%');
name |
---|
1BikeRoady |
Bike |
BikeRoad |
Road |
Road1 |
RoadBike |
SELECT name
FROM yourtable
WHERE
name IN ('Road','Bike','Hello World','Another Text');
name |
---|
Road |
Bike |
Another Text |
Hello World |