query help please



Hi,

I wanted to add the result of a second query to each row of a first query.
Example:
I have a query like this

select field1, field2 from t1 inner join t2 on t1.field11 = t2.field11

and I wanted the final result to have a 3 column with the result of the
following query using the values from the first query on the qhere clause of
the second

select field3 from t3 inner join t4 on t3.f22 = t4.f22
where field4 = field1 (value from the 1 query) and field5 <= field2 (value
also from the same query)

How can I do this?
Can it be done on a single query?
Thanks in advance

Pedro

--
real queries:

SELECT CAST(sectionDefinition.sectionID AS int) AS IDLinha,
sectionMainDefinition.sectionName AS NomeLinha, trainDefinition.node,
sectionDefinition.km1 AS pk, trainDefinition.sequence
AS sequence, nodesDefinition.commercialName AS Nomeestacao,
(SELECT DISTINCT TOP 1 tab_CK_Trocos.IDTroco
FROM sectionDefinition INNER JOIN
tab_CK_Trocos ON
sectionDefinition.node = tab_CK_Trocos.DepInicio
WHERE (sectionDefinition.histDate IS NULL)
AND (sectionDefinition.sectionID = IDLinha) AND (sectionDefinition.km1 <=
pk)) AS IDTROCO
FROM trainDefinition INNER JOIN
sectionDefinition ON trainDefinition.sectionID =
sectionDefinition.sectionID AND trainDefinition.node = sectionDefinition.node
INNER JOIN
sectionMainDefinition ON sectionDefinition.sectionID =
sectionMainDefinition.sectionID INNER JOIN
nodesDefinition ON trainDefinition.node =
nodesDefinition.nodeID
WHERE (trainDefinition.trainNumber1 = 180) AND (trainDefinition.histDate
IS NULL) AND (sectionDefinition.histDate IS NULL) AND
(trainDefinition.endDate > GETDATE()) AND
(sectionMainDefinition.histDate IS NULL) AND (nodesDefinition.histDate IS
NULL)
ORDER BY trainDefinition.sequence

.



Relevant Pages

  • Re: "Identical" query SQL Throws Error
    ... in the second query I was trying to set up a filter on the MYear ... The criteria on the Factory field ... FROM (tblEndItem INNER JOIN tblSPIData ON ... ...
    (microsoft.public.access.modulesdaovba)
  • Re: Duplicate Label_id History
    ... First query: Return just the scans you are interested in ... INNER JOIN (ScannAction ... FROM AccountAction INNER JOIN (ScannAction INNER JOIN (Employees RIGHT ...
    (microsoft.public.access.queries)
  • Re: IIF Statement to calculate aging buckets
    ... If Access says it's too complex, Access can't understand it -- incorrect may ... Now create a second query, ... all the fields from the first query, then add your original IIFstatement. ...
    (microsoft.public.access.queries)
  • Re: how do i count consecutive records with a field value >=1
    ... The first query consider for each record how many records in table ... The second query keep only the ranks where bal <0. ... but i don't have a clue how your sql got the results i needed. ...
    (microsoft.public.access.queries)
  • Re: IIF Statement to calculate aging buckets
    ... >> parameter needs to be defined as Date Type in the query. ... >> Jeff Boyce wrote: ... >>> Now create a second query, ... >>> all the fields from the first query, ...
    (microsoft.public.access.queries)