3
Insert queries use the MySQL INSERT statement. The INSERT statement follows the syntax of INSERT into <table Name> (<fields to populate>) values ('<values for fields>');. Fields and values are separated with a comma.
Basic insert statement populates field1, field2, and field3 with value1, value2 and value3 in table1.
This insert statement demonstrates MySQLs ability to do math on values in an insert statement. Here we set field1 to 25 field2 is 25 field3 is value3 and field4 set to 78. The math on insert statements may only be done on fields set prior to the current field.
Update queries are used to change values for rows already stored in a table. Syntax is UPDATE <table> SET <field>=<value> WHERE <field>=<value>;. The SET portion of the statement is where you put the columns to update and the values to update them, and the WHERE portion determines which rows to update.
This statement updates table1 setting field1 to "value1", field2 is added by one, and field3 is multiplied by two on any row that field4 equals 10.
Here we threw in a curveball you'll notice we've selected two tables. Also we've noted all fields in the format of table.column. This allows us to reference values in one table to set values in another table.