Like operator TSQL Tutorial

Like operator:

Cities table:

CITY_IDNAMESTATE
1New YorkNew York
2Los AngelesCalifornia
3ChicagoIllinois
4San AntonioTexas
5San DiegoCalifornia

Like Example 1:

Find the city name that contain letters: an.
SELECT * FROM cities WHERE name LIKE '%an%';

Like Result:

CITY_IDNAMESTATE
2Los AngelesCalifornia
4San AntonioTexas
5San DiegoCalifornia

Like Example 2:

Find the cities name that start with: Sa.
SELECT * FROM cities WHERE name LIKE '%Sa%';

Like Result:

CITY_IDNAMESTATE
4San AntonioTexas
5San DiegoCalifornia

Like Example 3:

Find the cities name that end with: go.
SELECT * FROM cities WHERE name LIKE '%go';

Like Result:

CITY_IDNAMESTATE
3ChicagoIllinois
5San DiegoCalifornia