选择From SQL database [英] Select From SQL database
问题描述
我正在尝试选择并在RadGrid上显示。我正在使用sqlDataSource。我有2个表(用户和经销商)。用户表我在DealerShip表上有属性(UserID(pk),UserName,Email,Phone和DealerShipID(fk))我有属性(DealerShipID(pk),DealerShipName),现在这就是我想要做的。在我的网格上我将像树视图一样向下钻取,DealerName将像一个masterview,在你向下钻取你可以找到属于该特定DealerShip的所有用户,例如我将有三个经销商(a,b,c) )每个都有不同的用户,业务规则(一个用户只能属于我的经销商,一个经销商可以拥有很多用户。)请帮助一个如何修改SELECT语句,这将显示每个经销商的所有用户?
谢谢。
I am trying to select and display on the RadGrid. i am using sqlDataSource. i have 2 Tables (Users and DealerShip). User table i have attributes (UserID(pk),UserName,Email,Phoneand DealerShipID(fk)) on DealerShip table i have attributes (DealerShipID(pk),DealerShipName) and now here is what i want to do. on my grid i will have a drill down like a treeView, the DealerName will be like a masterview where you drill down you can find all the users that belong to that specific DealerShip, for example i will have three Dealers (a,b,c) which have different users under each, Business Rule (one user can only belong to i Dealership and one Dealership can have many users.) please can one assist on how to right a SELECT statement which will display all the users per Dealership?
Thanks.
推荐答案
SELECT Users.UserName,dealership.dealershipname FROM Users INNER JOIN DealerShip ON Users.delearshipid = DealerShip.dealershipID和dealership.dealershipid = @dealershipid
SELECT Users.UserName,dealership.dealershipname FROM Users INNER JOIN DealerShip ON Users.delearshipid = DealerShip.dealershipID and dealership.dealershipid = @dealershipid
这篇关于选择From SQL database的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!