Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两张桌子。我需要执行一个查询,以获取包含该字母的产品名称,m并按这些产品的成分数量降序对这些产品进行排序。
m
product表中包含名称和产品编号,而表中Madefrom包含成分编号和产品编号。
product
Madefrom
像这样的东西:
SELECT Name, COUNT(MadeFrom.ID) FROM Product INNER JOIN MadeFrom ON MadeFrom.ProductID = Product.ID WHERE Name LIKE '%m%' GROUP BY Name ORDER BY COUNT(MadeFrom.ID) DESC