91-9990449935 0120-4256464 |
SQL UPDATEThe SQL commands (UPDATE and DELETE) are used to modify the data that is already in the database. The SQL DELETE command uses a WHERE clause. SQL UPDATE statement is used to change the data of the records held by tables. Which rows is to be update, it is decided by a condition. To specify condition, we use WHERE clause. The UPDATE statement can be written in following form: Let's see the Syntax: Let's take an example: here we are going to update an entry in the source table. SQL statement: Source Table:
See the result after updating value:
Updating Multiple Fields:If you are going to update multiple fields, you should separate each field assignment with a comma. SQL UPDATE statement for multiple fields: Result of the table is given below:
MYSQL SYNTAX FOR UPDATING TABLE: SQL UPDATE SELECT: SQL UPDATE WITH SELECT QUERY: We can use SELECT statement to update records through UPDATE statement. SYNTAX: You can also try this one - My SQL SYNTAX: If you want to UPDATE with SELECT in My SQL, you can use this syntax: Let's take an example having two tables. Here, First table contains - Cat_id, cat_name, And the second table contains - Rel_cat_id, rel_cat_name SQL UPDATE COLUMN: We can update a single or multiple columns in SQL with SQL UPDATE query. SQL UPDATE EXAMPLE WITH UPDATING SINGLE COLUMN: This SQL UPDATE example would update the student_id to '001' in the student table where student_name is 'AJEET'. SQL UPDATE EXAMPLE WITH UPDATING MULTIPLE COLUMNS: To update more than one column with a single update statement: This SQL UPDATE statement will change the student name to 'AJEET' and religion to 'HINDU' where the student name is 'RAJU'.
Next TopicSQL UPDATE with JOIN
|