It is possible towrite the INSERTINTO statement in two ways:
1. Specify both the column names and the valuesto be inserted:
INSERTINTO table_name (column1, column2, column3,...)VALUES(value1, value2, value3,...);2.If you are adding valuesforall the columnsof the table, you donot need to specify the column names in the SQL query. However, make sure the orderof the valuesisin the same orderas the columnsin the table. Here, the INSERTINTO syntax would be as follows:
INSERTINTO table_name
VALUES(value1, value2, value3,...);
-- if you want to insert values in all column-- values must be assigned to that columnINSERTINTO table_name
VALUES(value1, value2, value3,...);-- ^ ^ ^ ^-- (column1, column2, column3, ...)-- the same arrangement
-- the following statement inserts values value1, value2 and value3 -- into columns column1, column2, column3 respectivelyINSERTINTO table_name (column1, column2, column3)VALUES(value1, value2, value3);-- the following statement inserts the values in order into-- all the columns of the tableINSERTINTO table_name
VALUES(value1, value2, value3);
INSERTINTO sakila.actor
(first_name, last_name)# column names to insert intoVALUES("Ryan","Desmond");# values to insert into those columns (in the same order)# in SQL, the hashtag or pound sign is the comment symbol, just FYI
INSERTINTO name (...)VALUES(...)
Used alongside the INSERTINTO keyword toadd new valuesto a table.
Example: Adds a new car to the cars table.INSERTINTO cars (name, model,year)VALUES('Ford','Fiesta',2010);
-- sql insert using string format -- you dont need to do this unless you want to specify what-- columns you want to insert
⬇️
String ="INSERT INTO Marcas (yourcolumn) VALUES(if your value is string use 'your string' and if is a number you dont use the '')";-- exemple: -- because my idcostumer just allows numbers and that is a text one and i use the '' -- and i dont use the ''
⬇️ ⬇️
ssql ="INSERT INTO Costumer (idcostumer, costumername) VALUES("textboxidcostumer.Text+", '"+ textboxname.Text+"')";