douti6740 2017-11-19 14:52
浏览 144
已采纳

去mysql SELECT查询导致变量赋值错误

I'm new to Go and I'm trying to query a mysql database. I tried the following code:

rows, err := db.QueryRow("SELECT * FROM t_users")

But running the go run main.go gives this error:

cannot assign 1 values to 2 variables

But I don't get any errors for this:

rows, err := db.Query("DESCRIBE t_user")

How come my select statement is giving an error?

  • 写回答

1条回答 默认 最新

  • douyin2883 2017-11-19 22:07
    关注

    mkopriva's response

    QueryRow returns one value, Query returns two

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?