我想將我的 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, pricefrom orderhistory_t{{datetag}}并使用模板創(chuàng)建如下查詢:select '2014-01-01' as date, itemid, pricefrom orderhistory_t20140101union all select '2014-01-02' as date, itemid, pricefrom orderhistory_t20140102union all select '2014-01-03' as date, itemid, pricefrom orderhistory_t20140103如何遍歷 Golang 的切片并將它們放入 sql 模板中?
- 1 回答
- 0 關(guān)注
- 177 瀏覽
添加回答
舉報(bào)
0/150
提交
取消