The subquery is the inner query of the nested query. The outer query in the nested query uses the output from the subquery. We can use a subquery in where clause of select, insert, update, and delete statements.
Here is a syntax to write subquery in SQL:
WHERE ColumnName operator
(Select ColumnName from TableName where condition);
You can check out this SQL tutorial blog by Intellipaat to learn writing complex subqueries in SQL.