eXtropia: the open web technology company
Technology | Support | Tutorials | Development | About Us | Users | Contact Us
Resources
 ::   Tutorials
 ::   Presentations
Perl & CGI tutorials
 ::   Intro to Perl/CGI and HTML Forms
 ::   Intro to Windows Perl
 ::   Intro to Perl 5
 ::   Intro to Perl
 ::   Intro to Perl Taint mode
 ::   Sherlock Holmes and the Case of the Broken CGI Script
 ::   Writing COM Components in Perl

Java tutorials
 ::   Intro to Java
 ::   Cross Browser Java

Misc technical tutorials
 ::   Intro to The Web Application Development Environment
 ::   Introduction to XML
 ::   Intro to Web Design
 ::   Intro to Web Security
 ::   Databases for Web Developers
 ::   UNIX for Web Developers
 ::   Intro to Adobe Photoshop
 ::   Web Programming 101
 ::   Introduction to Microsoft DNA

Misc non-technical tutorials
 ::   Misc Technopreneurship Docs
 ::   What is a Webmaster?
 ::   What is the open source business model?
 ::   Technical writing
 ::   Small and mid-sized businesses on the Web

Offsite tutorials
 ::   ISAPI Perl Primer
 ::   Serving up web server basics
 ::   Introduction to Java (Parts 1 and 2) in Slovak

 

Introduction to Databases for Web Developers
Modifying Data  
It is also easy to modify an existing row using SQL. To do so, you will use the UPDATE operator which follows the basic format of:

    UPDATE table_name
    SET column_name = some_value
    WHERE where_clause;

For example, if we wanted to change the EMPLOYEES table such that Lim Sing Yuen received a $5,000 raise we would say:

    UPDATE EMPLOYEES
    SET  EMP_SALARY = (EMP_SALARY + 5000)
    WHERE EMP_NAME = 'Lim Sing Yuen';

or more directly:

    UPDATE EMPLOYEES
    SET  EMP_SALARY = 45000
    WHERE EMP_NAME = 'Lim Sing Yuen';

Note also that you can easily modify more than one column at once in the SET clause. For example, you might say:

    UPDATE EMPLOYEES
    SET  EMP_SALARY = 50000,
	 EMP_COMMISSION = '15%'
    WHERE EMP_NAME = 'Lim Sing Yuen';

You should also be aware, that if you did not specify a WHERE clause, then the operation affects all rows in the table. Thus the following code would give every employee a $5000 raise:

    UPDATE EMPLOYEES
    SET  EMP_SALARY = (EMP_SALARY + 5000);

Finally, note that the WHERE clause can be as complex as needed, including subqueries if desired. Consider this example in which we give raises to only those employees who make less than the average salary:

    UPDATE EMPLOYEES
    SET  EMP_SALARY = (EMP_SALARY + 1000);
    WHERE EMP_SALARY <
	(SELECT AVG(EMP_SALARY)
	 FROM EMPLOYEES);

Previous | Next | Table of Contents