Insert, replace, and update statements are used to insert or modify data in the database. Let's take a look at them one by one.
INSERT
inserts new rows into an existing table; the following is the syntax to add new rows to a table:
INSERT[INTO] tbl_name [(field_name1, field_name2...)] {VALUES|VALUE} ({value of filed 1},value of filed 2,...),(...),...
The following inserts new users into the user table:
Insert INTO user (first_name,last_name,email,password) VALUES ("Robert","Dotson","[email protected]","17500917b5cd7cefdb57e87ce73485d3"), ("Ruth","Uselton","[email protected]","17500917b5cd7cefdb57e87ce73485d3");
UPDATE
modifies data into an existing table; the following is the syntax to add new rows to a table:
UPDATEtable_referenceSETfield_name1="value"[,field_name2="value"]...
[WHEREwhere_condition]
[ORDERBY...]
[LIMITrow_count]
The following UPDATE
statement is used to update the first name in the users table:
UPDATE...