Pages

Friday, 29 November 2013

What are the guidelines for using SUB-QUERIES?



Answer
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:
Code:
SELECT name FROM students
     WHERE stud_id = (SELECT stud_id FROM class 
              WHERE last_name='abc'
                  AND first_name='xyz');

No comments:

Post a Comment

Enter Your Question

Total Pageviews

Blog