Presentation is loading. Please wait.

Presentation is loading. Please wait.

Session 5 SQL 2: how to Modify database content with SQL.

Similar presentations


Presentation on theme: "Session 5 SQL 2: how to Modify database content with SQL."— Presentation transcript:

1 Session 5 SQL 2: how to Modify database content with SQL

2 –INSERT INTO Customer VALUES (555, 'Yu', 'Jia','540 Magnolia Hall', ‘Greenwich', ‘London', ‘SE10 9LS', 0.00); –INSERT INTO Customer (firstName, lastName, accountId) VALUES ('Jia', 'Yu', 555); Modify content with INSERT statements These are written to the database in field order ie accountid, lastname, firstname, address1,address2,State,ZipCode,balance

3 UPDATE statements General form of update statement –UPDATE SET =,.. WHERE ; –Example - Update to mark every timecard as paid UPDATE TimeCard SET paid = true WHERE paid = false;

4 Update to give part time employees a 10% raise –UPDATE HourlyEmployee SET hourlyRate = hourlyRate * 1.1 WHERE EmployeeStatus = ’Part Time’;

5 DELETE statements Each delete statement deletes from one table according to some selection clause Delete every row from table –DELETE from Employee; Delete an hourly employee –DELETE FROM HourlyEmployee WHERE ssn = ’145-09-0967’;

6 SQL Statements in JavaScript <% varSurname= “Smith”; varFirstName = “Ray”; sql = “INSERT INTO tblCustomer (Surname, Firstname) "; sql=sql+" VALUES ('“+varSurname+"','"+varFirstnames+"‘);"; %> Becomes INSERT INTO tblCustomer (Surname, Firstname) VALUES ("Smith", "Ray"); Split the SQL statement over several lines [Single quote] [Double quote] [+] [Variable] [+] [Double quote] [Single quote]


Download ppt "Session 5 SQL 2: how to Modify database content with SQL."

Similar presentations


Ads by Google