Home > database >  Multi-table query, result, and then find file data from the results
Multi-table query, result, and then find file data from the results

Time:01-13

The select arjun achineid, A.c hangeid, B.m achinename, C.e dituser, D.p roductno, D.p roductname from tclassdata A
Inner join machine B on B.m achineid=arjun achineid
Inner join productchange C on Arthur c. hangeid=A.c hangeid
Inner join the product D on D.p roductid=C.p roductid
Where A.s tarttime> 08:00:00='2021-01-10' and A.e ndtime<08:00:00='2021-01-11'
And B.v isible=1

How to put the above query results as a list, and then extract the data from the virtual table, for example, I want to extract A.c hangeid maximum value, and press arjun achineid, B.m achinename, C.e dituser, D.p roductno, D.p roductname, grouping displayed

CodePudding user response:

"Group" means respectively group show? Is the same machineid, machinename edituser, productno, productname find out the five biggest changeid respectively?

CodePudding user response:

With a temporary table

CodePudding user response:

reference 1/f, kun jins kao kun jins kao response:
"group" means respectively group show? Is the same machineid, machinename edituser, productno, productname find out the five biggest changeid respectively?

Yes, yes, yes

CodePudding user response:

reference 1/f, kun jins kao kun jins kao response:
"group" means respectively group show? Is the same machineid, machinename edituser, productno, productname find out the five biggest changeid respectively?

Arjun achineid, A.c hangeid, B.m achinename, C.e dituser, D.p roductno, D.p roductname
1 1 1 1 1 1
1 2 1 1 1 1
I take A.c hangeid value of 2 of the row,

CodePudding user response:

Feel as though you say this directly take MAX (changeid) and GROUP BY the five fields is good...

CodePudding user response:

refer to 6th floor kun jins kao kun jins kao response:
feel you say this seems to be directly take MAX (changeid) and GROUP BY the five fields is good...

The five as long as there is a different, can yield two data, I only take one recently

CodePudding user response:

refer to 7th floor weixin_38922940 response:
Quote: refer to the sixth floor kun jins kao kun jins kao response:
feel you say this seems to be directly take MAX (changeid) and GROUP BY the five fields is good...

The five as long as there is a different, can yield two data, I just take a recent article

What do you mean only take a recently?
Arjun achineid, A.c hangeid, B.m achinename, C.e dituser, D.p roductno, D.p roductname
1 1 1 1 1 1
1 2 1 1 1 1
1 1 1 1 2
This kind of circumstance is retained a few data? If the retained a D.p roductname take 1 or 2, this field is taken by what rules?

CodePudding user response:

refer to the eighth floor kun jins kao kun jins kao response:
Quote: refer to 7th floor weixin_38922940 response:
Quote: refer to the sixth floor kun jins kao kun jins kao response:
feel you say this seems to be directly take MAX (changeid) and GROUP BY the five fields is good...

The five as long as there is a different, can yield two data, I just take a recent article

What do you mean only take a recently?
Arjun achineid, A.c hangeid, B.m achinename, C.e dituser, D.p roductno, D.p roductname
1 1 1 1 1 1
1 2 1 1 1 1
1 1 1 1 2
This kind of circumstance is retained a few data? If the retained a D.p roductname take 1 or 2, this field is taken by what rules?

A.c hangeid value there will not be repeated, so won't have this kind of situation,
A.c hangeid value is increasing, there will not be repeated

CodePudding user response:

refer to the eighth floor kun jins kao kun jins kao response:
Quote: refer to 7th floor weixin_38922940 response:
Quote: refer to the sixth floor kun jins kao kun jins kao response:
feel you say this seems to be directly take MAX (changeid) and GROUP BY the five fields is good...

The five as long as there is a different, can yield two data, I just take a recent article

What do you mean only take a recently?
Arjun achineid, A.c hangeid, B.m achinename, C.e dituser, D.p roductno, D.p roductname
1 1 1 1 1 1
1 2 1 1 1 1
1 1 1 1 2
This kind of circumstance is retained a few data? If the retained a D.p roductname take 1 or 2, this field is taken by what rules?

For the column say
Zhang SAN, at 1 o 'clock eat beef
Zhang SAN, at 2 o 'clock eat chicken
Last time ask Joe to eat what?
A: Joe, at 2 o 'clock eat chicken
Probably is one such means

CodePudding user response:

null