Watch Demo×

See NinjaOne in action!

What Is a Database Query?

what is a database query blog banner image

A database query is an essential component that enables the smooth functioning of databases, allowing users to retrieve, manipulate, and analyze data efficiently. This post seeks to shed light on what a database query is, the common languages used to write them, the types of queries, and a few practical examples.

What is a database query?

A database query can be defined as a request for data from a database. Usually, it is expressed in a structured query language such as SQL. A database query can either be a select query or an action query. The former is used to fetch data from the database, which matches the parameters set by the user. The latter, on the other hand, prompts a particular action to be performed on the data, like updating, inserting, or deleting data.

Common query languages

  1. SQL (Structured Query Language): SQL is one of the most widely used query languages. It is designed for managing data held in a relational database management system (RDBMS).
  2. QBE (Query By Example): This is a visual query language for relational databases. Instead of writing code, the user specifies an example of the data they are looking for.
  3. DMX (Data Mining Extensions): DMX is a language for data mining models. It allows users to create and manage data mining models within a database.
  4. MDX (Multidimensional Expressions): MDX is used for OLAP (Online Analytical Processing) databases. It allows users to compose queries to pull data from multidimensional databases.

Types of queries

Select queries

Select queries, often regarded as the most commonly used type of query, are employed to retrieve data from databases. In a select query, criteria are specified by users to define the precise information required from the database. The result of a select query is a new table, also known as the “result set,” composed of rows that meet the specified criteria.

Action queries

Action queries, unlike select queries, are used not just to retrieve data but to perform various actions on the data within the database. There are four types of action queries:

  • Update queries allow changes to be made to multiple records in one operation, based on specified criteria.
  • Append queries add records from one or more tables to another table.
  • Delete queries remove records from one or more tables in a database.
  • Make-table queries create a new table from records in one or more existing tables.

Parameter queries

Parameter queries are designed to prompt for specific input each time they are run, making them dynamic in nature. The user-inputted value becomes the criterion for retrieval of data. 

Aggregate queries

Aggregate queries, also known as summary or totalling queries, return a single calculated value derived from values across multiple rows and are often used in conjunction with group by statements. They can provide valuable insights into large volumes of data by performing calculations such as Count, Sum, Average, Min (for the smallest value), and Max (for the largest value). 

Crosstab queries

Crosstab queries, also known as matrix queries, display summarized values (sums, counts, and averages) from one field in a table and group them by one set of facts listed down the left side of the datasheet and another set of facts listed across the top of the datasheet.

Query examples

  1. SQL select query: SELECT * FROM Employees WHERE Salary > 50000; This SQL query selects all fields from the “Employees” table where the salary is greater than 50000.
  2. SQL update query: UPDATE Employees SET Salary = 60000 WHERE EmployeeID = 1; This SQL query updates the salary of the employee with ID 1 to 60000.


Database queries are crucial for managing and operating databases. They provide a flexible way to interact with stored data, offering various functionalities, from simple data retrieval to complex data manipulation. Understanding database queries is fundamental for anyone working with databases, as they form the backbone of any database operation. With the knowledge of common query languages and types of queries, one can effectively work with any database system.

Next Steps

Building an efficient and effective IT team requires a centralized solution that acts as your core service deliver tool. NinjaOne enables IT teams to monitor, manage, secure, and support all their devices, wherever they are, without the need for complex on-premises infrastructure.

Learn more about NinjaOne Endpoint Management, check out a live tour, or start your free trial of the NinjaOne platform.

You might also like

Ready to become an IT Ninja?

Learn how NinjaOne can help you simplify IT operations.

By clicking the “I Accept” button below, you indicate your acceptance of the following legal terms as well as our Terms of Use:

  • Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms.
  • Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party.
  • Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library belonging to or under the control of any other software provider.
  • Warranty Disclaimer: The script is provided “as is” and “as available”, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations.
  • Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks.
  • Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script.
  • EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).