This content has been marked as final. Show 6 replies
Welcome to the forum!
Whenever you post provide your 4 digit Oracle version.
I hava a table table A
select column b from table A where column b = value 1 and column c = value 2
I get value 1 from a select statement with where condition.
I get value 2 from 1 more different select statement using where conditions.
Then write a query that does just what you described above. Why is that an issue?
select column b from table A where column b = (select value from tableb where ...) and column c = (select ... from ....)
You need to review the subquery concept
where deptno =
(select deptno from dept where location='DALLAS')
If there are more you need to use IN instead of =
Senior Oracle DBA
998767 wrote:Depending on your requirements, you could use WITH clauses instead of nested sub-queries.
yeah...I will do nested or subquery......just verifying for better approaches.....
when should we prefer stored procedures???Mainly when something can't be done in pure SQL, or when the only way to do it in pure SQL is very convoluted and/or inefficient.
Of course, it is debatable what "very convoluted" is. A 6-line sub-query might not sound complicated, but it certainly is more complicated than a 1-line function call. If you find that a user-defined function makes your code easier to debug and maintain, then go ahead and use one, assuming that performance is acceptable. There is a certain overhead cost involved in calling any user-defined function from SQL, no matter how efficient the function itself is. There is often a trade-off; you'll have to decide if the neat, clear code that you get from a user-defined function justifies slower performance.