Skip to content

question about prepare where in #251

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

Closed
hsiaosiyuan opened this issue Jun 26, 2014 · 1 comment
Closed

question about prepare where in #251

hsiaosiyuan opened this issue Jun 26, 2014 · 1 comment

Comments

@hsiaosiyuan
Copy link

Hi,

I have a question about prepare query contains 'where in', here is my code:

stmt, err := db.Prepare("select user_id from user where user_id in ?")

I've tried these four ways:

// 1
stmt, err := db.Prepare("select user_id from user where user_id in ?")
rows, _ := stmt.Query(1, 11)

// 2
stmt, err := db.Prepare("select user_id from user where user_id in ?")
rows, _ := stmt.Query([]int{1, 11})

// 3
stmt, err := db.Prepare("select user_id from user where user_id in (?)")
rows, _ := stmt.Query(1, 11)

// 4
stmt, err := db.Prepare("select user_id from user where user_id in (?)")
rows, _ := stmt.Query([]int{1, 11})

all of them four got a panic like:

panic: runtime error: invalid memory address or nil pointer dereference

could you please give me a hand, if you could provide a example about that will be best

thank you.

@hsiaosiyuan
Copy link
Author

Sorry, I should to search if the same issue already exists.
If someone meet this same problem please see
#227

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

1 participant