Intern
What is the SELECT operator in SQL?
sobes.tech AI
Answer from AI
The SELECT operator is used to retrieve data from one or more tables in a database.
Main components of the SELECT operator:
- SELECT: Specifies the columns to be retrieved.
- FROM: Indicates the table(s) from which data is extracted.
- WHERE: Applies conditions to filter rows.
- GROUP BY: Groups rows with the same values in specified columns.
- HAVING: Applies conditions to groups created by
GROUP BY. - ORDER BY: Sorts the result set.
Example:
SELECT column1, column2 -- Select data from columns column1 and column2
FROM table_name -- Retrieve data from the table named table_name
WHERE condition -- Apply condition to filter rows
ORDER BY column1 DESC; -- Sort the result in descending order of column1