Iam writing a golang program in which i query postgres database. I want to to use $1 to supply values and should have a pattern matching
Db.Query("SELECT * FROM table where name like %$1%", user)
it says:
syntax error at or near "%"
Iam writing a golang program in which i query postgres database. I want to to use $1 to supply values and should have a pattern matching
Db.Query("SELECT * FROM table where name like %$1%", user)
it says:
syntax error at or near "%"
Your syntax is wrong, try
user := "%"+user+"%"
rows, err := Db.Query("SELECT * FROM table where name like $1", user)
if err!=nil{
fmt.Println(err)
}