Querying a Database

19/03/2020 1 By indiafreenotes

We query data every day from Google searches to asking Siri for a funny joke. Queries are simply questions against a set of data. They can become very complex, involving multiple tables and millions of records; however, the basic concept is straightforward and not very complex.

A database query is a request for data from a database. Usually the request is to retrieve data; however, data can also be manipulated using queries. The data can come from one or more tables, or even other queries.


As mentioned above, when we ask Siri for a joke, we are posing a question/query to the application. While the query behind the scenes is very complex and will search against many sources, the concept can be made quite simple.

A query starts with the keyword SELECT, no matter the system. This tells the database to go pick something; the details are after the SELECT statement. If we want all jokes, we use the asterisk (*), which tells the database to retrieve everything:

Query Working

Let’s say that you want to order an Americano at Starbucks. You make a request by saying “Can I have an Americano?”. The Barista will understand the meaning of your request and give you the ordered item.

A query works the same way. It gives meaning to the code used in any query language. Be it SQL or anything else, both the user and the database can always exchange information as long as they ‘speak’ the same language.

You may now think that placing a query is the only way to request data. In fact, quite a few database software options let you use other methods. The most popular ones are:

  1. Using available parameters

The software, by default, has lists of parameters on their menu. Users can choose one, and the system will then guide you to produce the desired output. It’s easy, but not flexible and offers limited operations.

  1. Query by example

The system will show you a set of code with some blank areas, in which you can write and specify the fields and values of your data.

  1. Query language

This is what we’ve been talking about. You have to write the queries from scratch whenever you want to manipulate data. This method requires understanding the query language used by your database software. Although it is complex, it gives you full control over your data.