I am running the below query, but only get the first id value:-
select * from `table` where table`.`id` in ('1', '2', '3', '4', '5', '6', '7', '9', '11', '13', '14', '15', '17') and `table`.`deleted_at` is null
I have done the following:-
var aID = make([]string, 0)
var in India // india is struct
for rows.Next() {
cook := rows.Scan(&in.ID)
aID = append(aID, strconv.Itoa(in.ID))
}
asID = strings.Join(aID, ",")
anotherRow,err := db.Query("SELECT * from table2 where id in (?)", asID)
if err != nil { fmt.Printf("Error: ", err) }
// ... Other line follows up with "for anotherRow.Next() and fetching"
While fetching data, it only returns value of "1" and ignores all other ID passed to it, which are '2', '3', '4', '5', '6', '7', '9', '11', '13', '14', '15', '17'
.
How can I pass it correctly?
I am using go-sql-driver/mysql
.
FAQ :
aID
does contain all those numbers as string andtable has all the rows available with provided above
id
.table
is from whereid
is fetched and appended toaID
and another record withid
stored inaID
are fetched within
statement fromtable2
.
Thanks