Interview Question: Match the Pattern

Sample Question #165 (programming – SQL)

What’s the difference between the following two WHERE statements:

1. WHERE (name LIKE ‘Brett%’);

2. WHERE (name LIKE ‘Brett_’);

This entry was posted in Sample Qs. Bookmark the permalink.

One Response to Interview Question: Match the Pattern

  1. Brett says:

    LIKE is SQL’s pattern-matching function. ‘Brett%’ matches any string with "Brett" followed by 0 or more characters (just like the * wildcard in DOS and UNIX shell). ‘Brett_" matches any string with "Brett" followed by exactly one character (just like ? in DOS and UNIX shell).

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s