V
V
vista1x2014-11-01 23:46:25
PHP
vista1x, 2014-11-01 23:46:25

How to rewrite a query?

MS Access has two queries of the following form:
1) a saved query called qr1

SELECT t1.field1 as fl1, Max(t2.field2) AS fl2
FROM t1 
INNER JOIN t2 ON t1.id = t2.id

2) the request takes data from the previous one
SELECT qr1.fl1, qr1.fl2
FROM qr1
WHERE fl2 < 50

Need to rewrite queries for use in PHP odbc. As far as I understand, ready-made queries from Access cannot be used in any way.
In fact, the queries are somewhat more complicated, I simplified. I would like to understand the principle of association.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Shahelm, 2014-11-02
@vista1x

Something like this:

SELECT temp.fl1, temp.fl2
FROM (
    SELECT t1.field1 as fl1, Max(t2.field2) AS fl2
        FROM t1 
    INNER JOIN t2 ON t1.id = t2.id
) as temp
WHERE temp.fl2 < 50

not sure if that's what you need.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question