X
X
xafiwo2019-04-19 19:31:12
go
xafiwo, 2019-04-19 19:31:12

How to get value from database with two WHERE parameters?

Hello!
There is a code:

rows, err := db.Query("SELECT * FROM speach WHERE speach_globalnumber=? AND speach_localnumber=?", globalSpeachNumber, localSpeachNumber)

I need to get a line/lines in which the speach_globalnumber and speach_localnumber fields correspond to the globalSpeachNumber, localSpeachNumber variables.
But, in the output I get an error:
sql: expected 6 destination arguments in Scan, not 5
exit status 1

Unfortunately, I couldn't figure it out on my own.
Please tell me what is the problem and in which direction to move?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Leonid Nikolaev, 2019-04-19
@xafiwo

It is not necessary to write select * in the code - then the sides will come out. Here's how in this case. You specified the wrong number of variables for reading in Scan.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question