1

Topic: Requests

I have 3 tables
I will describe the most important columns
The table the client with id the client and a name, the Goods with id the goods and the price, the Order with id the goods
As to me to deduce the client with the greatest total of the order

2

Re: Requests

untilthedayidie;
To read about JOIN
After you will learn to connect tables - to read about GROUP BY and SUM
When you will learn to group - read about ORDER BY and LIMIT

3

Re: Requests

It seems, you misunderstood me, my problem here in what, excuse, probably, it was necessary to write at once. Us acquainted with  on example Access (I do not know why), and so there requests are saved also you permanently can pull out result. We admit, it becomes here so there:
1
SELECT Klient. CodeKlient, SUM (Tovar. CenaEd*Zakaz. Kolich)
FROM Klient INNER JOIN (Tovar INNER JOIN Zakaz ON Tovar. CodeTovar=Zakaz. CodeTovar) ON Klient. CodeKlient=Zakaz. CodeKlient
GROUP BY Klient. CodeKlient;
2
SELECT Max ([Expr1001]) AS Expr1
FROM Query3;
3
SELECT Klient. Name, Query4.Expr1
FROM (Klient INNER JOIN Query3 ON Klient. CodeKlient=Query3.CodeKlient) INNER JOIN Query4 ON Query3.Expr1001=Query4.Expr1;
My problem that I do not understand how it to unite in normal MySQL, I something did not read up Mb, prompt, please.

4

Re: Requests

untilthedayidie wrote:

Us acquainted with  on example Access (I do not know why), and so there requests are saved also you permanently can pull out result.

that in terms MS Access "request" is called, in all DBMS is named by term View.

untilthedayidie wrote:

I do not understand, how it to unite in normal MySQL

The first variant - that in Access is generated as static request to create in MySQL as View.
The second variant - in data source of the last request in section FROM we replace a name of static request about its text framed with brackets, and the name is used as , i.e., for example, a fragment

Klient INNER JOIN Query3

Turns in

Klient INNER JOIN>>> (the full text of request Query3) AS <<<Query3

5

Re: Requests

In the latter case it is necessary to process in addition the interposed text so that in it and in exterior request there were no tables with the same name (i.e.  names and ).
By the way, the second method quite works and in Access when it is necessary to get rid of static subqueries and all to unite in one request. Here only such modular request categorically is not recommended to be translated in a design view - dies.