1

I have a table with data where in a situation one rows' id becomes another rows reference id. The table is as below.

enter image description here

I tried to retrieve data as below,

select * from table1 t where t.id = t.reference_id

but it returns empty table.

3
  • you should try a self join.. Commented Jan 29, 2018 at 6:11
  • 1
    like this:- select * from table1 inner join table1 h on t.id = t.reference_id Commented Jan 29, 2018 at 6:14
  • Specify the expected result as well. Formatted text, please! (I.e. no images....) Commented Jan 29, 2018 at 7:51

1 Answer 1

3

Try a self join like :

select * from table1 t1
inner join table1 t2 on t1.id = t2.reference_id
Sign up to request clarification or add additional context in comments.

Comments

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.