From the course: Learning SQL Programming

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Broadening and limiting responses

Broadening and limiting responses - SQL Tutorial

From the course: Learning SQL Programming

Start my 1-month free trial

Broadening and limiting responses

- [Instructor] While we usually want to be very specific when we're setting the conditions for what data we want back from the database, sometimes instead we need to be a little bit less specific about what we're asking to match, and to look for values that match some part of a field, but not all of it. For that, there's the LIKE operator. The LIKE operator works with a percent sign representing the part of the field we don't really care about. If we wanted to say, show me all the records whose state_code starts with the letter C, we could write out a long statement with logical OR operators, with state_code="CA", OR state_code="CO", OR state_code="CT", and so on. Or we could say state_code LIKE 'C%' This tells the database to match the letter C, and then whatever comes after it, we don't care about, regardless of how much information follows the letter C. We just care about records whose value in this field matches the first character. Or we can change that around and put N first…

Contents