My table function
func createTransactionTable(db *sql.DB) {
transaction := `CREATE TABLE IF NOT EXISTS Transaction_history(
"rollno" INTEGER UNSIGNED NOT NULL,
"isReward" INTEGER UNSIGNED NOT NULL,
"transfered_to" INTEGER UNSIGNED NOT NULL,
"transfered_amount" INTEGER UNSIGNED NOT NULL,
"redeems" INTEGER UNSIGNED NOT NULL,
"date" TEXT NOT NULL
);`
statement, err := db.Prepare(transaction)
if err != nil {
panic(err)
}
statement.Exec()
fmt.Println("trasaction table created")
}
query function
count, err := db.Exec(`SELECT count(isReward) from Transaction_history WHERE rollno = ? AND isReward = ?`, rollno, 1)
if err != nil {
panic(err)
}
if count != 0 {
return true
}
return false
I am trying to find the no of rows of in my table where isReward = 1 and rollno is as specified of our choice but is giving and i dont know how to achieve, i know it is a very basic but literally searched but didn't get anything that will fit my need, so need help