Options I have web app with a search bar. The search bar accepts customer_id's and runs a query to a redshift cluster with the customer_id as a filter. I need to be able to input multiple customer id's comma separated and then run the query filtered by those customer id's. Currently i can only use 1 customer id at a time. Here is what i currently use. Any help or guidance is appreciated.
func riiapp(w http.ResponseWriter, r *http.Request) {
oname := r.PostFormValue("orderid")
rows, err := db.Query("SELECT rma_id, order_id, customer_id, bin_id, owner, asin, lpn, warehouse_id FROM crt.returns_in_inv WHERE (warehouse_id IN ($1) OR lower(warehouse_id) IN ($1)) OR lpn IN ($1) OR asin IN ($1) OR rma_id IN ($1) OR customer_id IN ($1) OR ORDER_ID IN ($1);", oname)
if err != nil {
http.Error(w, http.StatusText(500), 500)
return
}
defer rows.Close()
bks := make([]Book, 0)
for rows.Next() {
bk := Book{}
err := rows.Scan(&bk.Rmaid, &bk.Orderid, &bk.Customerid, &bk.Binid, &bk.Owner, &bk.Asin, &bk.Lpn, &bk.Warehouseid) // order matters
if err != nil {
http.Error(w, http.StatusText(500), 500)
return
}
bks = append(bks, bk)
}
if err = rows.Err(); err != nil {
http.Error(w, http.StatusText(500), 500)
return
}
tpl.ExecuteTemplate(w, "riiapp.gohtml", bks)
fmt.Println(oname)
}
<html>
<div class="container" align="center">
<h6>Search By: Rma_Id, Order Id, Customer ID, Asin, LPN OR Warehouse ID (May Pull Many Records)</h6>
<form action="/riiapp" method="POST">
<input type="text" name="orderid" id="ord" placeholder="SEARCH">
<input type="submit">
</form>
<table id="testTable">
<thead valign="top">
<tr>
<th>Rma_id</th>
<th>Order_id</th>
<th>Customer_id</th>
<th>Bin_id</th>
<th>Owner</th>
<th>Asin</th>
<th>Lpn</th>
<th>Warehouse_id</th>
</tr>
</thead>
<tbody>{{range .}}
<tr>
<td>{{.Rmaid}}</td>
<td>{{.Orderid}}</td>
<td>{{.Customerid}}</td>
<td>{{.Binid}}</td>
<td>{{.Owner}}</td>
<td>{{.Asin}}</td>
<td>{{.Lpn}}</td>
<td>{{.Warehouseid}}</td>
</tr>
{{end}}
</tbody>
</table>
</div>
</html>