Syntax and examples for deleting records in a table PDF Print E-mail
User Rating: / 0
PoorBest 
Thursday, 16 July 2009

To delete a record we serve the DELETE statement. In this case we need to specify whom or what records you want to delete. It is therefore necessary to establish a selection process carried out by the WHERE clause.

How to select will be detailed in subsequent chapters. For now we are happy to show what kind of syntax used for these deletions:

Where conditions_of_selection DELETE FROM tbl_name

If we for example delete all records of the clients that we would be called Perico as follows:

Delete from clients where name = 'Perico'

Be careful with this command because if you do not specify a condition Where, what we are doing is to remove the table:

DELETE FROM customers

 

IF YOU WANT TO DELETE unequivocally CAN GO TO VARIOUS FIELDS AS A CONDITION OF TABLES:: EJ.

DELETE FROM TABLE
WHERE NAME = "RAMON"
AND NAME = "PERE"
 

If you have a table items eg:
Articulos
---------
code
price
Description

to erase any record would have to

DELETE FROM items WHERE code = 1

In this example the first article erased if the first one recorded ah correspond to the code number 1, if it has not erased the code with the value 1 is the position within the table with papers

can also be deleted according to the other fields, eg

DELETE FROM items WHERE price = 5

Here delete all items that cost 5 pesos

or even

DELETE FROM items WHERE description = "Coca Cola"

Here delete the article entitled coca cola

Last Updated ( Thursday, 16 July 2009 )
 
< Prev   Next >
School Joomla Templates and Joomla Tutorials