根据文档,我正在这样做
var thingname string = "asdf"; var id int err = database.QueryRow("SELECT id from things where thing = ?", thingname).Scan(&id)
但是Postgres在说
ERROR: syntax error at end of input at character 41 STATEMENT: SELECT id from things where thing = ?
我看不到我与演示代码有很大不同。我正在使用pq。
确切的语法取决于数据库。
用
err = database.QueryRow("SELECT id from things where thing = $1", thingname).Scan(&id)