SQL variables within a query


I try to do a query using sql variables but I got an error message from mysql that I have an error in the SQL I have written.

Is it possible to do something like this ? :

q := `SET @x=1; 
      SELECT id, @x+1 FROM my_table;
rows, err := db.Query(q)

I read: https://golang.org/pkg/database/sql/#DB.Query

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.