Skip to content

Instantly share code, notes, and snippets.

@yareally
Created November 20, 2015 19:56
Show Gist options
  • Save yareally/aa4395fd47bb9925135e to your computer and use it in GitHub Desktop.
Save yareally/aa4395fd47bb9925135e to your computer and use it in GitHub Desktop.
case class City(id: Long, name: String)
case class State(id: Long, abbr: String, name: String)
def citiesInPostal(postal: Long): DBIO[Seq[(City, State, Long)]] = {
sql"""SELECT c.id, c.name, s.id, s.abbr, s.name, csp.id
FROM location_identifier AS li,
cities AS c,
states AS s,
city_state_postal AS csp
WHERE csp.postal_code = ${postal}
AND csp.postal_code = li.postal_code
AND csp.city_id = c.id
AND csp.state_id = s.id
""".as[(City, State, Long)]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment