Your Question

My code is like db.Exec("INSERT INTO table1 (name) values ('test');SET @id=@@IDENTITY;INSERT INTO table2 (table1_id) values (@id)"). The question is symbol '@' is a marker parameter,how can i avoid '@' being replaced?

The document you expected this should be explained

Expected answer

Comment From: jinzhu

Please create a PR that failed to pass tests

Comment From: github-actions[bot]

This issue has been marked as invalid question, please give more information by following the Question template, if you believe there is a bug of GORM, please create a pull request that could reproduce the issue on https://github.com/go-gorm/playground, the issue will be closed in 2 days if no further activity occurs. most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: nocatsnolife

This is not a gorm bug .How can I keep the "@ "symbol in the final generated sql statement? @jinzhu

Comment From: github-actions[bot]

This issue has been marked as invalid question, please give more information by following the Question template, if you believe there is a bug of GORM, please create a pull request that could reproduce the issue on https://github.com/go-gorm/playground, the issue will be closed in 2 days if no further activity occurs. most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: jinzhu

This is not a gorm bug .How can I keep the "@ "symbol in the final generated sql statement? @jinzhu

I still don't get your idea, a pull request would be helpful for that.

Comment From: github-actions[bot]

This issue has been marked as invalid question, please give more information by following the Question template, if you believe there is a bug of GORM, please create a pull request that could reproduce the issue on https://github.com/go-gorm/playground, the issue will be closed in 2 days if no further activity occurs. most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: airani

I have the same problem For example @jinzhu https://stackoverflow.com/questions/10485769/mysql-update-a-column-with-an-int-based-on-order

Comment From: Airmole

所以这问题解决了吗?我也遇到了。。。

Comment From: aaronangxz

For those that are seeing this, we can do this https://gorm.io/zh_CN/docs/sql_builder.html#%E5%91%BD%E5%90%8D%E5%8F%82%E6%95%B0

db.Where("name1 = @name OR name2 = @name", sql.Named("name", "jinzhu")).Find(&user)
// SELECT * FROM `users` WHERE name1 = "jinzhu" OR name2 = "jinzhu"

Took me a while to find this :')