BESTPROOFINGSERVICE.COM

digital proof books - www.bestproofingservice.com

Menu


VALUES The actual values to be inserted. You could also use the SELECT statement within the INSERT statement to literally copy information


from one table to the other:   INSERT INTO Transactions (EmployeeID, Name, Email) SELECT EmployeeID, Name, Email FROM Employees WHERE EmployeeID = 1   The preceding statement, of course, assumes that we have a Transactions table. At any rate, this statement effectively copies from the Employees table the EmployeeID, Name, and Email whose EmployeeID is equal to 1 and copies this data into the Transactions table. The UPDATE Statement The UPDATE statement is used to define changes within your database tables. As you're probably aware, database information is not static, rather, it is constantly changing depending on user feedback or input. As an example, assume that an administrator wanted to change specific data (maybe a username and password) for a particular employee within the Employees table. To make these changes to an existing record in the table, an UPDATE statement would have to be used. The UPDATE statement requires certain keywords, operators, and usually a WHERE clause to modify the specific record, for instance:   UPDATE Employees SET Name = "Cammi" WHERE EmployeeID = 3   This statement effectively changes Cammy's name to "Cammi' since she matches the EmployeeID of 3. NOTE Operators enable you to connect certain portions of your statement, whereas clauses allow for more refined queries and searches. Both are discussed later in the chapter.   Of course, you don't have to use the EmployeeID field with the WHERE clause. Instead, you could use Cammy's name as follows:   UPDATE Employees SET Name = "Cammi" WHERE Name = "Cammy"   In this case, all instances of "Cammy" are replaced with "Cammi" in the database. The DELETE Statement The DELETE statement can be used to remove unneeded records from the database. For instance, if you wanted to remove all employees from the Employees table, we might write a DELETE statement as follows:   DELETE FROM Employees   The preceding statement effectively removes all the employees from the Employees table. Of course, this doesn't make much sense! You wouldn't want to just go and remove all employees from your database. Instead, you might want to delete a specific employeefor instance, if they were fired. If this were the case, you could append a WHERE clause to your statement to simply remove one record:   DELETE FROM Employees