If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Dynamic Recordset Processing

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-23-11, 07:46
2neilt 2neilt is offline
Registered User
 
Join Date: Aug 2011
Posts: 2
Dynamic Recordset Processing

Goal: Track " Electrical" change documents that impact Drawings

I have four tables, three of which document changes with the fourth identifying drawings. Change records are linked to the Drawings table in one to many relationship as one change may impact several drawings.

an SQL union query of the three change tables filters all changes "electrical" and I would like to further process this recordset to ultimatly report a drawing list with associated "electrical" changes only.

The drawing table is static but the Change tables are updated daily and the query is set to run on startup.

What is the best statergy for executing the above?
Reply With Quote
  #2 (permalink)  
Old 08-23-11, 08:38
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Code:
SELECT drawings.drawing_no
     , drawings.anothercolumn
     , changes.somecolumn
  FROM drawings
LEFT OUTER
  JOIN ( SELECT drawing_no
              , somecolumn
           FROM changes_table1
          WHERE type = 'electrical'
         UNION ALL
         SELECT drawing_no
              , somecolumn
           FROM changes_table2
          WHERE type = 'electrical'
         UNION ALL
         SELECT drawing_no
              , somecolumn
           FROM changes_table3
          WHERE type = 'electrical'
       ) AS changes
    ON changes.drawing_no = drawings.drawing_no
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 08-23-11, 09:16
2neilt 2neilt is offline
Registered User
 
Join Date: Aug 2011
Posts: 2
Thanks Rudy,

I will "checkout" your solution as my database is access 2007 and I will have to convert it to run in my VBA code.

I was pleased to see a local talent answer as I am a bit north of you in Barrie.

Thanks for the quick response and I will certainly checkout your book

Best Regards

neilT
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On