Hi Everyone.

I am having trouble writing a select statement to get some records from one table with a reference ID existing in another record. For example.

Table X has ID 1,2,4,6,9. And Table Y has ID 1,2,3,4,5,6,7,8,9.

How can I retrieve all the records in Table Y that has the ID 1,2,4,6 & 9 without using a do while loop?

I tried using the statement "select * from table Y where exists (select * from table X where Y.ID=X.ID)". But only one record is shown. Can any one explain why?