Modifying Row Data : Update « Insert Delete Update « SQL / MySQL






Modifying Row Data

  
/* Create the table */
Drop TABLE Professor;

CREATE TABLE Professor (
   ProfessorID INT NOT NULL PRIMARY KEY,
   Name        VARCHAR(50) NOT NULL)
TYPE = InnoDB;

/* Prepare the data */
INSERT INTO Professor (ProfessorID,Name) VALUES (1,'John Jones');
INSERT INTO Professor (ProfessorID,Name) VALUES (2,'Cury Butz');
INSERT INTO Professor (ProfessorID,Name) VALUES (3,'JJ Smith');


/* Real command */
  
UPDATE Professor 
SET Name = CONCAT('Prof. ', Name) 
   WHERE ProfessorID > 6;


           
         
    
  








Related examples in the same category

1.Do PLUS calculation in where clause
2.Assign value in select clause
3.Update with limitation and calculation
4.Update records with calculation based on two tables
5.Update two tables with calculation
6.Using UPDATE Statements to Modify Data in Joined Tables
7.Update with condition
8.UPDATE statement includes a WHERE clause
9.An UPDATE statement can be qualified by the use of the ORDER BY clause and the LIMIT clause.
10.Update statement using table name alias
11.Update value by calculation
12.Update statement with variable (ERROR 1093 (HY000): You can't specify target table 'PENALTIES' for update in FROM clause)
13.Update and order
14.Update with limit clause
15.UPDATE IGNORE
16.Update statement with case statement
17.Update statement with subquery (ERROR 1093 (HY000): You can't specify target table 'PENALTIES' for update in FROM clause)
18.Updates all rows with an InStock value of less than 30
19.Adding Subqueries to Your UPDATE Statements
20.Updating a joined table
21.When you update values in a joined table, you can update more than one value at a time
22.Joining Tables in an UPDATE Statement
23.A different join is defined in the UPDATE clause.
24.SET clause uses the Quantity column to specify the new value for that column