Can data in other tables be used for sorting by mysqlorder? In this case, can the userdtdg & nbsp; a1510 & nbsp; b1715B table field usertitle?& nbsp; axxx mysql order be sorted by data from other tables?
This is the case.
Table A field user dt dg
A 15 10
B 17 15
User title assignment in Table B
A xxx 1
B xxx 0
B xxxxx 0
A xxxxx 0
B xxxxx 1
To achieve this, calculate the number of user-related data in Table B based on the user values in Table A and Table B, and sort the data in descending order of the number of data entries, then the output result is
Number of Entries in user dt limit B
B 17 1 3
A 15 1 2
------ Solution --------------------
Select A. *, T. distinct from A, (select user, count (*) as distinct from B) T where A. user = T. user order by T. includesc
------ Solution --------------------
Select. user,. dt, sum (B. alias) as alias, count (B. user) as counter from a inner join B on. user = B. user group by B. user order by counter desc;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service