SQL with Jupyter Notebook Tutorial

20 / 61

Updating data in a table

Values of one or more columns of a table can be updated with the 'update' command to store new required values.

Syntax:

update table_name SET field1 = new_value1, field2 = new_value2
[where Clause]
INSTRUCTIONS

See all the records in your deptt_<<your lab username>> table:

%%sql
select * from deptt_<<your lab username>>

Update the 'Laker Street' to 'Maker Street'.

%%sql

update deptt_<<your lab username>>
set depstreet = 'Maker Street' where depstreet = 'Laker Street';
select * from deptt_<<your lab username>> ;

The following is another eample of update, in which we change the values of date and depstreet where depcity is Delhi.

%%sql

update deptt_<<your lab username>>
set depopendate = STR_TO_DATE('20170610','%Y%m%d'), depstreet = 'Saker Street' where depcity = 'Delhi';
select * from deptt_<<your lab username>> ;

No hints are availble for this assesment

Answer is not availble for this assesment


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...