I have 2 files. First file contains the list of row ID\'s of tuples of a table in the database. And second file contains SQL queries with these row ID\'s in \"where\" clause
You don't need regexps, so grep -F -f file1 file2
grep -F -f file1 file2