xxxxxxxxxx
-- 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 + "')";
xxxxxxxxxx
--sql insert quest example
INSERT INTO table_name (column1, column2, column3, )
VALUES (value1, value2, value3, );
xxxxxxxxxx
--SQL Insert Example with real data example
INSERT INTO Customers (CustomerName, ContactName)
VALUES ('Cardinal', 'Tom B. Erichsen');
xxxxxxxxxx
INSERT INTO Campus (Campus_Name, Address, Zip, Phone_No)
VALUES
('Nairobi Campus', '123 Moi Avenue, Nairobi', '00100', 0712345678),
('Mombasa Campus', '456 Kilindini Road, Mombasa', '80100', 0723456789),
('Eldoret Campus', '789 Main Street, Eldoret', '30100', 0734567890),
('Kisumu Campus', '987 Lake Road, Kisumu', '40100', 0745678901),
('Nakuru Campus', '654 Kenyatta Avenue, Nakuru', '20100', 0756789012);
xxxxxxxxxx
-- the following statement inserts values value1, value2 and value3
-- into columns column1, column2, column3 respectively
INSERT INTO table_name (column1, column2, column3)
VALUES(value1, value2, value3);
-- the following statement inserts the values in order into
-- all the columns of the table
INSERT INTO table_name
VALUES(value1, value2, value3);
xxxxxxxxxx
INSERT INTO Customers(customer_id, first_name, last_name, age, country)
VALUES
(5, 'Harry', 'Potter', 31, 'USA');
xxxxxxxxxx
INSERT INTO tableName
VALUES (‘anydata’, ‘anydata’, ‘anydata’, ‘anydata’, NULL,
NULL);
xxxxxxxxxx
-- if you want to insert values in all column
-- values must be assigned to that column
INSERT INTO table_name
VALUES
(value1, value2, value3, );
-- ^ ^ ^ ^
-- (column1, column2, column3, )
-- the same arrangement
xxxxxxxxxx
Add new rows to a table.
Example: Adds a new vehicle.
INSERT INTO cars (make, model, mileage, year)
VALUES ('Audi', 'A3', 30000, 2016);