To delete records in a table in DB2 database DELETE command is used, this command is well known in other databases and their use is similar in DB2.

DELETE FROM [Table]

As shown in the above syntax, the DELETE command only needs to receive as parameter the name of the table, but there is a very important item to be considered. When using the command as shown before all records are deleted and in many cases this format does not apply, due the WHERE clause is used with it.

DELETE FROM [Table] WHERE [Conditional]

In the syntax shown earlier, only records that satisfy the conditional will be deleted. As a practical example we will delete products from a table using both formats.

DELETE FROM product

DELETE FROM product WHERE cod_prod = 1

n the first example all products will be deleted from the table, in the second only the product that has the code 1 will be deleted.

ibm-db2

DB2 has gained more space in web development environments and because it understand it works becomes a great advantage. So, discover the advantages of working with DB2 on PHP projects on our official site.

You might also like…

Scriptcase & Web Services

This time I will explain how to work with web services inside the Scriptcase, directly with PHP and...

More updates in 9.4 version

Recently version 9.4 was released bringing a new design concept to the generated applications of Sc...

Taking a look at version 9.4

Scriptcase released its version 9.4, and this one brings many interesting news, specially regarding...

Comment this post

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at sales@scriptcase.net. Learn more about our Privacy Police.