MySQL需要对保留字进行反对勾选的表格.我有一个表格角色,这是一个保留字,但我已经把我的查询放在后面的刻度中,所以我可以在多行上写它(这是一个玩具查询,大的不适合一行......).
我如何逃避背蜱?
这是我的代码:
dbmap := db.InitDb()
var roles []entities.Role
query :=
` << Difficult to see with SO's code editor widget, but here is a back tick
SELECT *
FROM `Role` <<< Needs escaping
` << Difficult to see, but here is a back tick
_, err := dbmap.Select(&roles, query, nil)
if err != nil {
panic(err)
}
fmt.Println(roles)
Run Code Online (Sandbox Code Playgroud) go ×1