w3reference home
SQL Tutorial


Bookmark and Share

Deleting Data

The DELETE statement deletes the specified record/row from the specified table.
Syntax:
DELETE FROM table_name
WHERE some_column = some_value;
The above syntax is just one way to represent this statement. The "where" clause can contain any combination of operators and as many conditions as needed. The omition of the "where" clause causes all the records in the table to be deleted since it's the "where" clause which specifies which records have to be deleted. So be careful !!

Example:

ssn fname lname address city state
512687458 Joe Smith 83 First Street Howard Ohio
758420012 Mary Scott 842 Vine Ave. Losantiville Ohio
102254896 Sam Jones 33 Elm St. Paris New York
876512563 Sarah Ackerman 440 U.S. 110 Upton Michigan

Suppose we want to delete the record of Joe Smith. The query for the same would be:

DELETE FROM Emp_Add
WHERE fname = 'Joe' AND lname = 'Smith';
The resultant table will be:

ssn fname lname address city state
758420012 Mary Scott 842 Vine Ave. Losantiville Ohio
102254896 Sam Jones 33 Elm St. Paris New York
876512563 Sarah Ackerman 440 U.S. 110 Upton Michigan

This SQL query will delete all the records that have fname as Joe and lname as Smith. Had there been another row having the same fname and lname, it would have been deleted as well. In case you forget to put the WHERE clause, all the records in the Emp_Add table will be deleted. So be careful. !!

Code Validator
Learn FTP
Color finder
Link Checker
Free web designs
Coming soon!
Interview Questions...
'w3reference : Learn by examples ... Advanced to beginner's tutorials ...'
Ajax: AJAX tutorial1 | Apache: Apache HTTP Server | Restarting Apache | CSS: CSS Border | CSS Syntax | CSS Selector | CSS Comment | CVS: CVS Release | CVS Login | CVS Logout | CVS Annotate | Databases: Rolap Tutorial | OLAP Tutorial | OLTP Tutorial | data warehousing | Expect: HTML: html | Linux: Dot (.) conf files | Linux Mount Point | Linux Filesystem | SSH Tutorial | Linux Commands: cal | cat | cfdisk | chroot | MySQL: MySQL Commands | PHP: PHP Basics | PHP Variables | PHP Output (echo/print) | PHP String Concat | PL/SQL: PL/SQL Data Types | PL/SQL Control Structures | PL/SQL File Extensions | PL/SQL DBMS_OUTPUT package | Python: My first Python program | Shell: Starting Bash | Bash Redirection | Bash Pipes | Bash Variables | SQL: SQL Transactions | SQL Constraints | SQL Drop | SQL Union & Union All | SVN: svn architecture | SVN Repository | SVN Import | SVN Checkout | Tech: soap | Web Designing: Web Hosting | HTML/XHTML/CSS code validator | Learn FTP | Search Engine Optimization Tips | www: XML: XML vs HTML | XML Syntax | XML Tags, Elements and Attributes | XML Namespaces |
Sitemap | Disclaim | Privacy Policy | Contact | ©2007-2009 w3reference.com All Rights Reserved.