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_’);

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

One Response to Interview Question: Match the Pattern

  1. Brett says:

    ANSWER
     
    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:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s