SQL UPDATE with JOIN

SQL UPDATE JOIN means we will update one table using another table and join condition.

Let's see the syntax of SQL UPDATE query with JOIN statement.


					 UPDATE customer_table



 INNER JOIN



 Customer_table



 ON customer_table.rel_cust_name = customer_table.cust_id



 SET customer_table.rel_cust_name = customer_table.cust_name

					

SQL UPDATE DATE

How to update a date and time field in SQL? If you want to update a date & time field in SQL, you should use the following query. let's see the syntax of sql update date.


 UPDATE table



 SET Column_Name = 'YYYY-MM-DD HH:MM:SS'



 WHERE Id = value

Let us check this by an example:

Firstly we take a table in which we want to update date and time fields.

If you want to change the first row which id is 1 then you should write the following syntax:


 UPDATE table



 SET EndDate = '2014-03-16 00:00:00.000'



 WHERE Id = 1 

					

Note: you should always remember that SQL must attach default 00:00:00.000 automatically.

This query will change the date and time field of the first row in that above assumed table.