Skip to main content

What is an SQL query?

An SQL query is an instruction written in SQL, which a user or program uses to reach a database, to retrieve, change, or manage data.

The main points

  1. Retrieving data: a query can pull information from tables. Example:
sql
SELECT Name, Age FROM Employees WHERE DepartmentID = 101;
  • shows the names and ages of employees in a specific department.
  1. Adding data: a query can insert new records into a table. Example:
sql
INSERT INTO Employees (Name, Age, DepartmentID) VALUES ('Anna', 28, 102);
  1. Changing data: a query can update existing records. Example:
sql
UPDATE Employees SET Age = 29 WHERE Name = 'Anna';
  1. Deleting data: a query can delete records. Example:
sql
DELETE FROM Employees WHERE Name = 'Anna';
  1. Managing structure: queries can create or change tables and the relationships between them (DDL, Data Definition Language).

Put simply, an SQL query is a way to "talk" to a database, to get the data you need and manage it.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.