Last active
October 9, 2020 15:22
-
-
Save sjtalkar/f4634f4e54c70c60b35ecf794b18b91f to your computer and use it in GitHub Desktop.
SQL for partial string comparison
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--Option 1 | |
select metropolitanarea, | |
nhl_team, | |
team, | |
win, | |
loss | |
from cities_expanded c, | |
nhl_data n | |
where n.team like '%' || nhl_team || '%'; | |
--Option 2 | |
select metropolitanarea, | |
nhl_team, | |
team, | |
win, | |
loss | |
from cities_expanded c, nhl_data n | |
where n.team ~ nhl_team ; | |
--Option 3 | |
select metropolitanarea, | |
nhl_team, | |
team, | |
win, | |
loss | |
from cities_expanded c, nhl_data n | |
where position(c.nhl_team in n.team ) > 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment