Skip to content

Instantly share code, notes, and snippets.

@jonstorer
Last active June 26, 2017 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonstorer/1f31e4edfe5203d94c63e5387a2b3670 to your computer and use it in GitHub Desktop.
Save jonstorer/1f31e4edfe5203d94c63e5387a2b3670 to your computer and use it in GitHub Desktop.
sql query

users

id name age
1 Randy 30
2 Steve 40
3 Lori 50

phone_numbers

id user_id number type can_sms
1 1       5555555551 Home false
2 2       5555555552 Work true
3 3 5555555553 Home false
4 2 5555555554 Cell true
5 3 5555555553 Home true

I'd like to find all users who have a phone numbers of type "Work" and "Cell". To be clear, I don't want the user if they have one and not the other. I just want the user record if they have both.

I want to find

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment