INFO
Lecture 11 - Modifying DBs and using MySQL - annotated

Lecture 11 - Modifying DBs and using MySQL - annotated -...

Info icon This preview shows pages 1–3. Sign up to view the full content.

1 Modifying DBs and using MySQL INFO/COM S 230: Intermediate Web Design and Programming Modifying databases via SQL We can INSERT tuples into a relation, UPDATE tuples, and DELETE tuples from a relation. INSERTs INSERT INTO relation VALUES ( value1, value2, …, valuek ); E.g. INSERT INTO Movies VALUES (‘American Beauty’, 1999, 122); 201 mins. 2003 The Return of the King 113 mins. 2002 Chicago 2004 2001 2000 Year Length Title 132 mins. Million Dollar Baby 135 mins. A Beautiful Mind 155 mins. Gladiator Another variant INSERT INTO Movies(Length, Title, Year) VALUES(122, ‘American Beauty’, 1999); Using queries for INSERTs We can use the result of queries to do an INSERT. INSERT INTO Movies(Title, Year) SELECT DISTINCT Title, Year FROM StarsIn WHERE (Title, Year) NOT IN (SELECT Title, Year FROM Movies); Easy PDF Creator is professional software to create PDF. If you wish to remove this line, buy it now.
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.