sql - how to insert multiple row in single query in PostgreSQL -
i have variable holds multiple data, , want insert multiple data postgresql database using single query.
the field on table this: stud_tbl(id,fname,lname)
and variable holds multiple data;
variable = (123,ron,lum),(234,nald,bay),(345,rol,lumz)
my query:
str = "insert stud_tbl values ('" & variable & "')"
when execute query error , can't identify error.
to expand on @patrick's comment:
variable = "(123,'ron','lum'),(234,'nald','bay'),(345,'rol','lumz')"
the query:
str = "insert stud_tbl values " & variable
though usual warnings (how can prevent sql injection in php?) not being best practice apply.
Comments
Post a Comment