mirror of https://github.com/go-gorm/gorm.git
commit
371cd41204
|
@ -845,6 +845,12 @@ for rows.Next() {
|
||||||
}
|
}
|
||||||
|
|
||||||
db.Table("users").Select("users.name, emails.email").Joins("left join emails on emails.user_id = users.id").Scan(&results)
|
db.Table("users").Select("users.name, emails.email").Joins("left join emails on emails.user_id = users.id").Scan(&results)
|
||||||
|
|
||||||
|
// find a user by email address
|
||||||
|
db.Joins("inner join emails on emails.user_id = users.id").Where("emails.email = ?", "x@example.org").Find(&user)
|
||||||
|
|
||||||
|
// find all email addresses for a user
|
||||||
|
db.Joins("left join users on users.id = emails.user_id").Where("users.name = ?", "jinzhu").Find(&emails)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Transactions
|
## Transactions
|
||||||
|
|
Loading…
Reference in New Issue