Skip to content

Instantly share code, notes, and snippets.

@yutakahashi114
Created January 19, 2020 13:22
Show Gist options
  • Save yutakahashi114/a8c56da28b65e9ad1469ca6098e2f5f2 to your computer and use it in GitHub Desktop.
Save yutakahashi114/a8c56da28b65e9ad1469ca6098e2f5f2 to your computer and use it in GitHub Desktop.
subQuery := builder.
Select("id").
From("users").
Where(builder.Eq{"last_name": "テスト"}).
Where(builder.Like{"last_name", "テスト"}).
Where(builder.In("last_name", "テスト", "テスト2")).
Where(builder.In("last_name", []string{"テスト", "テスト2"})).
Where(builder.Eq{"first_name": "太郎2"}.
Or(builder.Eq{"first_name": "太郎3"}).
Or(builder.Eq{"first_name": "太郎4"}),
).
Where(builder.Gte{"created_at": t}).
Where(builder.IsNull{"deleted_at"})
fs := []friend{}
err = engine.
In("friend_id", subQuery).
Limit(10, 10).
Asc("id", "friend_id").
Desc("user_id").
Find(&fs)
if err != nil {
log.Println(err)
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment