It depends on your where clause.
For example this would be one way to approach it:
SELECT id. field1, CASE WHEN field2 LIKE 'test%' THEN 'test' ELSE 'apple' END AS matched_on
WHERE (field2 LIKE 'test%' OR field2 LIKE 'apple%')
But without more details we can't help much.