README.md

This commit is contained in:
Gwendal Roué committed 2015-10-27 15:49:18 +01:00
1 parent 299e7ef05b
commit d64b49cf8e
1 file changed
+16
+16
View File
@@ -486,6 +486,14 @@ dbQueue.inDatabase { db in
let emails = String.fetch(db,
"SELECT emails FROM persons WHERE email LIKE ?",
arguments: ["%@domain.com"])
// The emails of people who own at least two pets:
let emails = String.fetch(db,
"SELECT persons.email " +
"FROM persons " +
"JOIN pets ON pets.masterId = persons.id " +
"GROUP BY persons.id " +
"HAVING COUNT(pets.id) > 1")
}
```
@@ -1395,6 +1403,14 @@ dbQueue.inDatabase { db in
let persons = Person.fetch(db,
"SELECT * FROM persons WHERE email LIKE ?",
arguments: ["%@domain.com"])
// All persons who own at least two pets:
let persons = Person.fetch(db,
"SELECT persons.* " +
"FROM persons " +
"JOIN pets ON pets.masterId = persons.id " +
"GROUP BY persons.id " +
"HAVING COUNT(pets.id) > 1")
}
```