[ Home  |  FAQ-Related Q&As  |  General Q&As  |  Answered Questions ]


    Search the Q&A Archives


...differences between the following sql commands. ...

<< Back to: [FAQ] Oracle Database FAQ

Question by Dillip
Submitted on 7/5/2004
Related FAQ: [FAQ] Oracle Database FAQ
Rating: Not yet rated Rate this question: Vote
What is the differences between the following sql commands.
Here the "emp" table is in-built table for the oracle-8 database. And here in the first case I have used the "NOT IN" where as in the second case I have put the values directly.
So plz tell me why the first is not working.

1> select * from emp where empno not in
   (select mgr from emp);
2>select * from emp
where empno not in(7889,7798,7698);


Answer by ZASHA
Submitted on 1/24/2005
Rating: Not yet rated Rate this answer: Vote
First will not work b/c nested query will not return "empno" instead it will return "mgr".

 

Answer by Biski
Submitted on 12/20/2005
Rating: Not yet rated Rate this answer: Vote
Dilip,

Result will be same.But,
1.Now u have only 3 values for mgr column .Consider that u have 100 values for mgr,at that time u have to enter the all 100 values.that is time waste and leads to typographical errors while entering the values.

2.First query is ultimate and no need to change the query whenever changes occured to the data. In case of second u have to change the query whenever database updates.

 

Your answer will be published for anyone to see and rate.  Your answer will not be displayed immediately.  If you'd like to get expert points and benefit from positive ratings, please create a new account or login into an existing account below.


Your name or nickname:
If you'd like to create a new account or access your existing account, put in your password here:
Your answer:

FAQS.ORG reserves the right to edit your answer as to improve its clarity.  By submitting your answer you authorize FAQS.ORG to publish your answer on the WWW without any restrictions. You agree to hold harmless and indemnify FAQS.ORG against any claims, costs, or damages resulting from publishing your answer.

 

FAQS.ORG makes no guarantees as to the accuracy of the posts. Each post is the personal opinion of the poster. These posts are not intended to substitute for medical, tax, legal, investment, accounting, or other professional advice. FAQS.ORG does not endorse any opinion or any product or service mentioned mentioned in these posts.

 

<< Back to: [FAQ] Oracle Database FAQ


[ Home  |  FAQ-Related Q&As  |  General Q&As  |  Answered Questions ]

© 2008 FAQS.ORG. All rights reserved.