What is SELECT query in SQL?

The SELECT query in SQL is used to retrieve data from a database.

Syntax:

SELECT column1, column2,...
FROM table_name;

It only returns the values of column1 & column2.

But what if I have millions of columns in our DB? How do I retrieve all the data?

To retrieve all data from a database I use asterisk (*).

SELECT * FROM employees;

enhanced (23).jpg

Questions:

Q. When can a function NOT be called from a SELECT query?

Ans:

If the function includes DML operations like INSERT, UPDATE, DELETE etc then it cannot be called from a SELECT query.

Because the SELECT statement cannot change the state of the database.