Perform queries on tables is a typical activity in any DBMS and DB2 is no different, using the SELECT command that action can be easily accomplished as shown in the following syntax:

SELECT [Columns] FROM [Table]

Note that the syntax is similar to the syntax used in other databases such as MySQL, SQL Server and Firebird, for example. That’s because they all use PL / SQL as a standard language.

As a practical example, we will perform a simple query on a table that stores sales in an online store.

SELECT * FROM Sales

O carácter (*) é utilizado para que todos os campos sejam exibidos na consulta, caso seja necessário exibir campos específicos basta indicá-los no comando, como mostra o próximo exemplo.

SELECT Date, Seller FROM Sales

In this command only the columns date and seller will be displayed.

You still have the option of using the WHERE clause if you want to make filters and commands ORDER BY and GROUP BY to sort and group.

SELECT Date, Seller FROM Sales WHERE cod_sale = 1

SELECT Date, Seller FROM Sales ORDER BY Date

SELECT Date, Seller FROM Sales GROUP BY Seller

ibm-db2

The database IBM DB2, is undoubtedly a great choice when it comes DBMS to have numerous features and can be used in applications of various sizes. Want to know more? Then visit our official page about DB2 in PHP projects.

You might also like…

PROCESAMIENTO AJAX EN SCRIPTCASE

Ajax en los formularios de Scriptcase puede usarse para recargar un campo de tipo de select basado e...

IMPORTAR IMAGENES DE LA BASE DE DATOS Y UTILIZAR CLASES DE BOOSTRAP

Como muchas personas ya saben, Bootstrap es una biblioteca de front-end libre y de código abierto p...

TENDENCIAS DE DESARROLLO WEB PARA 2017

Usted verá en este post tendencias para 2017 en Diseño Web, en el medio digital y en el desarrollo...

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.