T-SQL Tutorial

T-SQL Some operator


The SOME subquery is pretty similar to ANY in the sense that they specify the need for a comparison. Therefore, comparison operators must be present. In fact, they can be used interchangeably as they aim to achieve the same goal within your database.


Cities table:

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

States table:

STATE_IDNAME
1Arizona
2California
3Texas
4Michigan

Some Example:

Find the cities that have the state in the states table using = some.
SELECT * FROM cities c
WHERE c.state = SOME (SELECT s.name FROM states s );

Result:

CITY_IDNAMESTATE
2Los AngelesCalifornia
4San AntonioTexas
5San DiegoCalifornia