Sobes.tech
Junior — Middle

What basic SQL queries have you used to retrieve data?

sobes.tech AI

Answer from AI

The following basic queries are usually used to retrieve data from a database using SQL:

  • SELECT — the main query for fetching data from tables.
  • WHERE — filtering data based on a condition.
  • ORDER BY — sorting the results.
  • JOIN — combining data from multiple tables.
  • GROUP BY — grouping data by specific fields.
  • LIMIT (or TOP in some DBMS) — limiting the number of rows returned.

Example of a simple query to get a list of users over 18 years old, sorted by name:

SELECT id, name, age
FROM users
WHERE age > 18
ORDER BY name ASC;

In Java, executing such queries typically involves using JDBC or ORM frameworks, which allow sending SQL queries and receiving results for further processing.