Query (General & Data): Definition, Pronunciation & Examples

Whether you want a general definition or need to understand database queries, they’re both rooted in the same core concept. Simply put, queries are questions.

But not all questions are alike. There are “yes and no” questions, open-ended questions, close-ended questions, free response questions, and more.

In this article, I’ve broken down queries into types to explain different meanings you can expect to encounter. And this for both general queries and database queries — because the two are inherently connected.

In short, a query is a request for any kind of information through any medium (written, spoken, sign-language, etc.). However, a database query is a request for information that’s written in code (usually SQL) with specific parameters such as search value, location, data type, length, size, and other conditions.

Let’s look at definitions, pronunciation, and examples to ensure we understand different types of queries.

Definition of Query

According to Oxford Languages Dictionary, a query is defined as “a question, especially one expressing doubt or requesting information.” Oxford Languages uses real-world sampling to curate its dictionary, which means this definition reflects current usage, not historical meaning.

According to Oxford Languages Dictionary, a query is defined as “a question, especially one expressing doubt or requesting information.”

The “doubt” portion of this definition is important. Because all questions seek information, “query” may seem synonymous with “question.” However, not all questions express doubt. A query, thus, differs from a question insofar as it shows uncertainty.

Database Query Definition

If you work in a digital environment, then you probably hear “query” used in the context of databases and data tables. While there is no official definition for database query, there are necessary characteristics.

A database query:

  • Must be written or transcribed into code that an underlying database can read
  • Must specify a data point to look for (i.e find the site “AnalystAnswers.com”)
  • Must specify the location where the data can be found
  • Must specify any conditions of the query (i.e find the site “AnalystAnswers.com” when the topic is data, not finance or business analysis)

Given these characteristics, we can define database query as “a request for information from a database that is written in code (usually SQL) and specifies a dimension or data point to search for in a data table, the specific location of that data, and any conditions of the search such as type, length, size, or other.

A database query is a request for information from a database that is written in code (usually in SQL) and specifies a dimension or data point to search for in a data table, the specific location of that data, and any conditions of the search such as type, length, size, or other.

We will look at examples of database queries in SQL below. Skip ahead to see it now!

How to Pronounce “Query”

Pronunciation is tough. In short, you break it into two sounds: “queer” and the letter “e”. Phonetically, you would write it as “ka-weer-ee.” Here’s a soundbit:

How to Pronounce “Query”

Types of Queries

A query is a question, but not all questions are the same. This dynamic introduces further granularity to queries in general and in databases.

There are 3 types of questions:

  • Yes/no
  • 5 Ws + How Questions (Who, What, When, Where, Why, How)
  • Choice questions

Each of these is either open-response or closed-response:

  • Yes/no – Closed-response
  • 5 Ws + How Questions (Who, What, When, Where, Why, How) – Open-response
  • Choice questions – Open-response

All of these are queries. Let’s look at some examples to get a better idea of the mechanics:

  • Yes/no. Closed. Are you in the library? This question requires a binary response. On/off, yes/no, 1/0.
  • Who. Open. Who is it? This question requires at least a one-word response that’s not binary.
  • What. Open. What are you doing? This question requires at least a one-word response that’s not binary.
  • When. Open. When will you arrive? This question requires at least a one-word response that’s not binary.
  • Where. Open. Where are you going? This question requires at least a one-word response that’s not binary.
  • Why. Open. Why did move to a new home? This question requires at least a one-word response that’s not binary.
  • How. Open. How did you move to a new home? This question requires at least a one-word response that’s not binary.
  • Choice. Open. Do you like chocolate or vanilla more? This question requires at least a one-word response that’s not binary.

All of these questions can be considered general queries. But which ones can be database queries? This part is key.

Database queries are only yes/no queries! Why? Because they use a matching logic. As we’ll see below, database queries receive an input data point and run it through a database on a binary basis. If there’s a match, or “yes,” then the result is output. If there is no match, or “no”, then there is no output.

Database queries are only yes/no queries!

Common Examples of Database Queries (That You Might Not Know)

  • Google search. That’s right, every time you search something in Google, it’s a query to the Google database.
  • Search bar on AnalystAnswers.com. Similarly, when you search for a word on a website’s search bar, this is a query as well. You’re asking the site to return all “yes” matches to your keyword.
  • Folder on a computer. When you click a folder on your computer, you’re asking the computer to retrieve and display information matching that folder’s name, location, and other conditions.

Common example of what’s NOT a database query:

  • Calculator. A calculator takes the input from your fingers and sends signals to transistors that turn either on or off (binary). Based on a system of logic gates (AND, OR, etc.) the calculator then compares the numbers based on the operator you provided. It sends back a number thereafter. Because there is no database of numbers, there is no query.
  • Computer Mouse. Similarly, when you click your mouse on a window, you’re asking the computer to create an output given signals to its transistors — not look in a database.
  • Keyboard. Again, when you type a character, you’re asking the computer to create an output given signals to its transistors — not look in a database.

Example of Query Using SQL

SQL allows programmers to extract, modify, and upload data in a data table. Since a query is a request for information, the extract function is what we’re looking for. The SQL statement used to extract data, or query data, is called SELECT.

The syntax for SELECT is as follows:

SELECT column1, column2, ...
FROM table_name;

Imagine you have a data table of cars called Cars that looks like this :

CarWeight (tonnes)ColorYear
Altima1.75Blue2020
Honda Accord1.5Black2010
Honda CIvic2White2015

The Weight column and Color columns can be queries using the following code:

SELECT Weight, Color
FROM Cars

If you would like to query the full data table, you can simply write SELECT *:

SELECT *
FROM Cars

As you can see, SQL runs binary, yes/no queries for each of the items outlined in the query. If the table matches Cars, it’s used. If the column matches Weight and Color, it’s used. However, if you wrote SELECT Hight FROM Cars, the output would be empty because the match is negative.

Types of Data Used for Query

When you run a query, it’s important to know what data type you’re searching with. At the highest level, data types can be divided into strings (aka text) and numbers.

Thereafter, the division can be broken down into the following five types:

  • Integer – any number that doesn’t have a decimal point
  • Date – a date of a given year and month
  • Time – the time of day
  • Text – often referred to as “string,” means simply any combination of letters instead of numbers or other symbols
  • Boolean – TRUE or FALSE data, often migrated to YES or NO text, or 1 and 0 numbers. It is, in simple terms, binary data.

Why is it important to be aware of data type? When you run a query, SQL will assume a data type to match for. However, if the relevant column’s default type is different, SQL may not recognize the match.

For example, if you search for a date “January 31, 2021” then SQL will look for a string. But if the data is stored as 31/01/2021 then the match won’t work. This becomes even more important when abbreviated dates vary by region. In Europe, for example, this date may be represented as DD/MM/YYYY rather than MM/DD/YYYY as is the case in the United States.

SQL vs NoSQL Queries

In the above examples we’ve covered queries in tabular databases, where data is stored in tables composed of rows and columns. These are SQL databases, but different queries are required for NoSQL databases.

In a sentence, the difference between SQL databases and NoSQL databases is that NoSQL data storage does not consist of a tabular form. Instead, data is stored in key–value pair, wide column, graph, or document. This structure means one item in a “table” can have different columns. There is no consistency.

Why is this important to queries? Because without a standardized structure, analysts cannot run the classic SELECT column FROM data table query. It simply doesn’t exist in NoSQL queries!

Instead, NoSQL queries look for a specific item across all documents in a database — there is no specification of table. For example, imagine you have many documents containing the word “cook” somewhere inside them. When you query the word “cook” you will an output with various fields and values from many different “tables.” From that point, you use logical constraints such as AND, OR, and NOT to refine the search.

A NoSQL query may look like the following:

> db.customer.find( {gender: "female", likes: "cook"} )

This query will then return a series of documents matching these criteria with — each several lines of information, but not all the same! Some may have more information, and others less. Why? Because the underlying structure is not tabular — it’s key-value.

These are very simplified examples of NoSQL. AnalystAnswers.com has a data page with loads of content on data analysis — check it out to learn more.

Conclusion

If you found this article helpful, feel free to check out more free content at the AnalystAnswers.com homepage!

About the Author

Noah

Noah is the founder & Editor-in-Chief at AnalystAnswers. He is a transatlantic professional and entrepreneur with 5+ years of corporate finance and data analytics experience, as well as 3+ years in consumer financial products and business software. He started AnalystAnswers to provide aspiring professionals with accessible explanations of otherwise dense finance and data concepts. Noah believes everyone can benefit from an analytical mindset in growing digital world. When he's not busy at work, Noah likes to explore new European cities, exercise, and spend time with friends and family.

LinkedIn

Scroll to Top