www.webdeveloper.com
Results 1 to 2 of 2

Thread: Question about data retrieval from nested SELECT

  1. #1
    Join Date
    Mar 2010
    Posts
    1

    Question about data retrieval from nested SELECT

    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?

    Code:
    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!

  2. #2
    Join Date
    Oct 2009
    Posts
    658
    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

    Code:
    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)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles