0

below is my query

select p.problem_id,
       p.problem_title,
       p.description,
       paps.problem_external_source_id, 
       paps.problem_and_problem_source_id 
  from problem_backup p,
       problem_and_problem_source paps 
 where p.problem_id=paps.problem_id and paps.free_user_id!='null';

My question is how to select another table columns based on the retrieved columns(i.e in my query i want to select some more columns from another table based on problem_and_problem_source_id) that is retrieved ,i want to do it in the same query,can we do the whole work in procedures..

2
  • which table's column do you want to display and what is the join criteria Commented Jul 9, 2012 at 6:28
  • Yep, as sashi said you're looking for what's called a "join" which temporarily combines two tables (by matching a column from one table to another) what do your tables look like? Commented Jul 9, 2012 at 6:34

1 Answer 1

1

You could join the another table in same way. Notice paps.free_user_id!='null' should be paps.free_user_id is not null, only except if you means the user_id is really string 'null'.

select p.problem_id,
       p.problem_title,
       p.description,
       paps.problem_external_source_id, 
       paps.problem_and_problem_source_id,
       yat.*
from problem_backup p
inner join problem_and_problem_source paps
  on  p.problem_id = paps.problem_id
inner join your_another_table yat
  on paps.problem_and_problem_source_id = yat.join_column_name
where  paps.free_user_id is not null
Sign up to request clarification or add additional context in comments.

3 Comments

can we go all this stuff with stored procedures
If you mean can this query be used inside a stored procedure then yes. If you mean can you use a stored procedure to perform the same function as a join, why on earth would you want to do that?
thanks for replying Braiba,which is the best way....i want to use this query in stored procedure

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.