linzhengen / tech-notes

My tech notes write in github issues🧲
1 stars 0 forks source link

[20201007] sqlx.Namedとsqlx.Inの使用法 #16

Open linzhengen opened 4 years ago

linzhengen commented 4 years ago
arg := map[string]interface{}{
    "published": true,
    "authors": []{8, 19, 32, 44},
}
query, args, err := sqlx.Named("SELECT * FROM articles WHERE published=:published AND author_id IN (:authors)", arg)
query, args, err := sqlx.In(query, args...)

参考URL http://jmoiron.github.io/sqlx/#namedParams