type Result struct {
Countryid int
Area string
Code string
}
var res Result
db.Raw("select countryid, area, code from wed_country_bak where countryid = ?", 172).Scan(&res)
Error 1047 (08S01): Unsupported command(COM_STMT_PREPARE) why ?
Comment From: helloBingGeGe
if write like this:
sql := db.ToSQL(func(tx *gorm.DB) *gorm.DB {
return tx.Raw("select countryid, area, code from wed_country_bak where countryid = ?", 172)
})
var res Result
db.Raw(sql).Scan(&res)
it works !
Comment From: saeidee
Please try to reproduce it in a Playground PR, I couldn't reproduce it.
Comment From: helloBingGeGe
Please try to reproduce it in a Playground PR, I couldn't reproduce it.
The reason is because I use Doris as the database, and there would be no problem if I use MySQL.
Comment From: zhao1532072926
I hava the same case when i use doris,but it can be resovled by set interpolateParams=true in mysql url. https://github.com/go-sql-driver/mysql/issues/360