Multiple choice technology databases

There is a % sign in one field of a column. Say for example table test_chk has a column name1 which contains a value “desdf%dsf”. What will be the queries to find it?

  1. SELECT * FROM test_chk ;

  2. select * from test_chk where name1 like '%%\%' escape ''

  3. select * from test_chk where name1 like ' \ ' escape '';

  4. select * from test_chk where name1 like '%!%%' escape '!'

Reveal answer Fill a bubble to check yourself
A,D Correct answer
Explanation

To find a literal '%' in SQL LIKE, you need an escape character. Option A (SELECT *) works but returns ALL rows inefficiently. Option D uses '!' as escape - '%!%%' means: any characters, then literal % (escaped as %!), then any characters. Option B is wrong (syntax error), and C doesn't match the pattern.