What are the guidelines for using SUB-QUERIES?
Following things need to be kept in mind when you write sub-queries:
- Caution should be taken with simple sub-query, especially when a normal value operator is used on the results of a sub-query, only one field must be returned.
- If you want to check for the existence of a single value within a set of other values, use the IN keyword as an operator upon the result set from a sub-query.Example of a Sub-Query:
SELECT name FROM students
WHERE stud_id = (SELECT stud_id FROM class