Definition:
A query is a request formulated to retrieve information from a system. In a search engine, it consists of the words, phrases, questions or operators that a person enters to obtain results. In a database, it is a structured instruction that requests, changes or combines data.
The term should not be confused with a query language, which provides the syntax for constructing queries, or with a query string, which is the part of a URL after the question mark and contains parameter and value pairs. It is also unrelated to jQuery, a JavaScript library.
Table of contents
What a query consists of
In search engines, a query may contain a single word, a sequence of terms or a complete question. The search engine interprets its meaning, context and intent to select and rank the results it considers most appropriate.
Some services support operators that modify the search. Quotation marks can request a phrase match, for example, while the site: operator can restrict results to a domain. These elements form part of the query but are not required for an ordinary search.
Queries are also submitted to the internal search engines of ecommerce websites, publishers, applications and help centres. In these cases, the system retrieves information from its own catalogue or index.
Search query analysis
Query analysis reveals how people express a need and which results they expect to find. In SEO, the queries that generate impressions and clicks help analyse organic visibility, although they are not all reported with the same level of detail.
In search advertising, the terms used by searchers can be compared with the keywords and advertisements in a Google Ads campaign. This review can identify relevant searches, new opportunities and terms that should be excluded.
Internal site searches also reveal which products, content or answers visitors are trying to find. They need to be interpreted alongside the context, the results provided and subsequent actions because query frequency alone does not demonstrate that something is missing.
Types of search query
Queries can be grouped by their predominant intent, although the same wording may support more than one interpretation:
- Informational: These aim to learn, answer a question or understand a subject, such as how to compress an image.
- Navigational: These aim to reach a particular website, page or service, such as Gmail login.
- Commercial investigation: These compare options before a decision, such as best web analytics tools.
- Transactional: These express the intention to complete an action, such as buying, booking, downloading or requesting information.
Difference from database queries
A query in a database follows the rules of its language and system. In SQL, for example, an instruction that retrieves available products might take this form:
SELECT product_name FROM products WHERE available = 1;
This query requests the product_name field from rows in the products table that satisfy the stated condition. Unlike a web search, the operation acts on a defined data structure and uses formal syntax.
