Say I want to check if a title name contains "stack" or contains "over" or contains "flow". Can I shorten the below code?
select name
from Title
where name like '%stack%' or name like '%over%' or name like '%flow%'
;
Thanks!
You could use REGEXP_LIKE, however that may have performance implications, so you may want to test it for your specific use case;
SELECT name
FROM Title
WHERE REGEXP_LIKE(name, '.*(stack|over|flow).*')
...or if you want the match case insensitive you can pass i as a third parameter;
SELECT name
FROM Title
WHERE REGEXP_LIKE(name, '.*(stack|over|flow).*', 'i');
LIKE. You could useREGEXP_LIKE, however that may have performance implications so may not necessarily be a good idea just to type less SQL. Let me know if you want me to add an example as an answer.