Click to See Complete Forum and Search --> : Question about data retrieval from nested SELECT


AK-85
03-10-2010, 10:20 AM
Hi everybody,
I have a database in Access and one of my queries has 7 SELECT statements. The problem is that I have multiple inheritance and I have to retrieve information from the super most class and combine it with information from the sub most class but I change the primary key. It looks something like this:

The result from the previous SELECT statments has one nr column and then I have B(*id_U, nr) -> A(data1, data2, id).

So to say, I have in the result some numbers, that corespond to data1 and data2 in A via the nr and id. I have to output nr, data1, data2. How can I do that? I can output only data1 and data2, but how do I add the nr?

SELECT A.data1, A.data2
FROM A
WHERE A.id IN (SELECT B.id_U
FROM B
WHERE B.nr IN (SELECT ...));

Thanks in advance!

ssystems
03-19-2010, 09:34 PM
What stops you from using JOINS? If you're database is normalized properly using joins is faster than subquery. In that scenario you'll have


SELECT A.data1, A.data2, B.nr
FROM table_A as A
JOIN table_B as B ON A.id_U = A.id
WHERE B.nr (SET YOUR FILTERS HERE OR JOIN AGAIN TO THE OTHER TABLES W/CE SUITS YOUR REQUIREMENTS)