1

Given that I have a table (tblFiles) with a field for fileNames, I need to use each DISTINCT filename returned from this table as an OR in the WHERE clause of another query. What is the best way to setting this up dynamically? All of my code is in VBA but if possible I would like to be able to run all of this querying logic in SQL.

So the first query would just pull the fileNames field from the table:

SELECT fileName FROM tblFiles GROUP BY fileNames;

the next query would be something like:

SELECT dateMade, invenNum, shipDate
FROM tblOrders
WHERE fileName = fileName1 
   OR fileName2 
   OR fileName3 (... the output from the first query)
4

1 に答える 1

2

あれについてどう思う:

SELECT * FROM tblFilms 
WHERE tblFilms.Filename IN (SELECT DISTINCT fileNames FROM tblFiles);

?

于 2013-10-17T11:42:07.730 に答える