0

I am trying to create a query in which 1st query will return COLUMN, based on the result of 1st query 2nd query will execute:

SELECT OBJECT_ID from test.CORRELATION_SET
WHERE (NAME='STATUS' AND VALUE ='SUCCESS')
|OBJECT_ID|
|---------|
|A        |
|B        |
|C        |
|---------|
SELECT * FROM test.CORRELATION_SET
WHERE OBJECT_ID = ('A'|'B'|'C');
2
  • 2
    SELECT * FROM CORRELATION_SET WHERE OBJECT_ID in (SELECT OBJECT_ID from CORRELATION_SET WHERE (NAME='STATUS' AND VALUE ='SUCCESS') ) Commented Apr 28, 2013 at 5:54
  • @DannyBeckett Thank you, Answer with my thought posted. Commented Apr 28, 2013 at 5:58

2 Answers 2

3

Following is the query

SELECT * FROM CORRELATION_SET
WHERE OBJECT_ID in (
  SELECT OBJECT_ID from CORRELATION_SET
  WHERE (NAME='STATUS' AND VALUE ='SUCCESS')
)
Sign up to request clarification or add additional context in comments.

Comments

1

Your example doesn't really make sense, it looks like you miss named the table in your second query.

SELECT * from test.CORRELATION_SET WHERE (NAME='STATUS' AND VALUE ='SUCCESS')

The above query would return the same results as your two queries. Assuming your second query used a table called CORRELATION_SET2, you could use the nested query that Kumar used in his comment. You could also use a join.

SELECT set2.* FROM test.CORRELATION_SET set1
    JOIN test.CORRELATION_SET2 set2 ON set2.object_id = set1.object_id
WHERE
  set1.name = 'status' and set1.value = 'success';

1 Comment

thanks Logan for you answer but just want to update you, that you can use the result of 1 query into another query by using Nested Select statments .

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.