我想将我的 SQL 查询与UNION ALLgolang http://golang.org/pkg/text/template/ 连接起来
例如,我有:
var slice1 = []string{"2014-01-01", "2014-01-02", "2014-01-03"}
var slice2 = []string{"20140101", "20140102", "20140103"}
并查询:
select {{.date}} as date, itemid, price
from orderhistory_t{{datetag}}
并使用模板创建如下查询:
select '2014-01-01' as date, itemid, price
from orderhistory_t20140101
union all
select '2014-01-02' as date, itemid, price
from orderhistory_t20140102
union all
select '2014-01-03' as date, itemid, price
from orderhistory_t20140103
如何遍历 Golang 的切片并将它们放入 sql 模板中?
相关分类