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_ID | NAME | STATE |
1 | New York | New York |
2 | Los Angeles | California |
3 | Chicago | Illinois |
4 | San Antonio | Texas |
5 | San Diego | California |
States table:
STATE_ID | NAME |
1 | Arizona |
2 | California |
3 | Texas |
4 | Michigan |
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_ID | NAME | STATE |
2 | Los Angeles | California |
4 | San Antonio | Texas |
5 | San Diego | California |