Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --If you know the name of the students who are studying science subject, you can get their id's by using this query below,
- SELECT id, first_name
- FROM student_details
- WHERE first_name IN ('Rahul', 'Stephen');
- --but, if you do not know their names, then to get their id's you need to write the query in this manner,
- SELECT id, first_name
- FROM student_details
- WHERE first_name IN (SELECT first_name
- FROM student_details
- WHERE subject= 'Science');
- Subquery Output:
- ----------------------
- | student details |
- |--------------------|
- | id | first_name |
- |-------|------------|
- | 100 | Rahul |
- | 102 | Stephen |
- ----------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement