1

I've just started learning Golang.

I followed the example_test in Golang source ExampleDB_Query_multipleResultSets

then I modified my query likely:

`
create table uid (id bigint);

select id from user where age < ?;

SELECT user.id, user.name FROM user JOIN uid ON user.id = uid.id;

select ur.user, ur.role from user_roles as ur join uid on uid.id = ur.user;
`

table user:

+-------+--------------+------+-----+---------+----------------+
| Field | Type         | Null | Key | Default | Extra          |
+-------+--------------+------+-----+---------+----------------+
| name  | varchar(255) | YES  |     | NULL    |                |
| age   | int(11)      | YES  |     | NULL    |                |
| id    | int(11)      | NO   | PRI | NULL    | auto_increment |
+-------+--------------+------+-----+---------+----------------+

and uid:

+-------+------------+------+-----+---------+-------+
| Field | Type       | Null | Key | Default | Extra |
+-------+------------+------+-----+---------+-------+
| id    | bigint(20) | YES  |     | NULL    |       |
+-------+------------+------+-----+---------+-------+

I recieved the error from log:

2017/02/21 14:44:08 Error 1064: 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 'select id from user where age < ?;

SELECT user.id, user.name FROM user JOIN uid' at line 3
exit status 1
khue bui
  • 1,366
  • 3
  • 22
  • 30

0 Answers0