Here's why:
* Procedural languages focus on *how* to achieve a result. They involve a sequence of steps, like instructions in a recipe. You specify the exact order of operations to be performed.
* Declarative languages focus on *what* you want, not how to get it. They describe the desired outcome, and the system figures out the best way to achieve it.
Query languages like SQL are declarative because:
* You specify the data you want (e.g., "select all employees where salary > $50,000").
* You don't tell the database how to find that data. The database engine figures out the most efficient way to execute your query.
Think of it this way:
* Procedural: "Go to the kitchen. Open the fridge. Take out a bottle of milk. Pour it into a glass. Drink it."
* Declarative: "I want a glass of milk."
However:
There are some aspects of query languages that can be considered procedural:
* Order of operations: Some SQL commands, like JOINs, can be used in different orders, affecting the result.
* Functions: Functions can contain logic, which could be considered procedural.
In general:
Query languages are primarily declarative, but they can have procedural elements. The focus is on specifying what you want, not how to get it.