Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL error #147

Open
Leadrive opened this issue Apr 21, 2019 · 2 comments
Open

SQL error #147

Leadrive opened this issue Apr 21, 2019 · 2 comments

Comments

@Leadrive
Copy link

[SELECT create_at, id, read_flag, message, relation_field, relation_id, remark
FROM user_messages
WHERE user_id = ? AND read_flag = ? AND valid = 1 ORDER BY create_at DESC LIMIT ?, ? 114820 0 0 20] file="inform.go:169" id=0
ERRO[2019-04-22 00:05:03] Received #1064 error from MySQL server: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''0', '20'' at line 3"

I use database/sql and github.com/ziutek/mymysql/godrv
this is a simple sql, why report error?

@Leadrive
Copy link
Author

the same sql, in github.com/go-sql-driver/mysql, it will work ok.

@ziutek
Copy link
Owner

ziutek commented Apr 21, 2019

What are "114820 0 0 20"? Probably arguments to this query.

It seems that the following text is sent to the MySQL server:

SELECT create_at, id, read_flag, message, relation_field, relation_id, remark
FROM user_messages
WHERE user_id = ? AND read_flag = ? AND valid = 1 ORDER BY create_at DESC LIMIT ?, ? 114820 0 0 20

and MySQL server parser complains near ''0', '20''.

You don't provide any real code that sends this query so I can't tell much more.

If you use database/sql the go-sql-driver is probably better option for you.

MyMySQL is rather intended to use without database/sql for MySQL specific applications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants