From 2adfd70bb5e92ecf91186f4414cdb59f73513314 Mon Sep 17 00:00:00 2001 From: Daniel Perez Date: Wed, 13 May 2015 14:20:20 +0900 Subject: [PATCH] Add examples for join. --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index c4ff661d..21707a8c 100644 --- a/README.md +++ b/README.md @@ -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) + +// 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