I have a requirement where I need to search a few columns in the table to see if the letter or word passed in as parameter is contained in any of those columns and return the first 100 rows. For example:
select id, col1, col2, col3 from table where col1 like '%word%' or col2 like '%word%' or col3 like '%word%' order by col1 offset 50 rows fetch next 100 rows only
I know that using a % as the beginning and end of a like operation will result in index scan. Is there a better way to write these kinds of queries? Thanks!