如何根据id获取数据 [英] How to get data according to the id
本文介绍了如何根据id获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2张桌子。
团体和客户。
i have 2 tables.
Group and customer.
Group Customer
group_Id Name customer_Id CusName groupId
1 sri lanka 1 Anne 1
2 india 2 John 2
3 japan 3 Mark 1
i希望根据groupId对此表进行分组,我想要根据报告中每个groupId顶部的groupId显示名称
我尝试了什么:
i want to group this tables according to the groupId and i want to display the name according to the groupId in the top of the each groupId in a report
What I have tried:
SELECT Customer.CustomerID,Customer.CusName ,Customer.CreditAllowed,CusGroup.groupId FROM Customer
INNER JOIN CusGroup on Customer.GroupID=CusGroup.groupId
GROUP BY Customer.CustomerID,CusGroup.groupId
ORDER BY CusGroup.groupId
i尝试这个,但我不知道显示名称
i try this but i dont know to display the name
推荐答案
检查这个:
Check this:
SELECT Cg.groupId, Cg.Name, Cu.CustomerID, Cu.CusName, Cu.CreditAllowed
FROM Customer Cu INNER JOIN CusGroup Cg on Cu.GroupID=Cg.groupId
ORDER BY Cg.groupId, Cu.CustomerID
这篇关于如何根据id获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文