从C#中的多个表加载页面 [英] Loading a page from multiple tables in C#
问题描述
我的SQL数据库中有10个以上的表。我需要根据某些条件(基于用户)加载包含此数据的页面。这是最好的方法吗?
谢谢,
我尝试了什么:
根据条件和检索值写一个存储过程(包含10 +表)。
但在某些情况下只有一个表就够了。所以我觉得我的方式并不好。
I have more than 10 tables in my SQL database. I need to load a page with this data, based on some conditions ( based on User) .Which is the best way to approach ?
Thank you,
What I have tried:
Wrote a stored procedure( with 10 + tables included), based on the condition and retrieve values.
But in some cases only one table is enough .So i feel my way is not good.
推荐答案
每个能够获得有关用户的信息。对于Eg。在一个表联系信息,第二个表员工详细信息,第三个表地址详细信息等...每个表都包含用户ID。
我需要获得的一些情况来自联系表或其他一些情况的值可能来自两个表。但是显示页面只是相同的。
Each able is having info about user. for Eg. in one table contact info,second table employee details,3 rd table address detail etc... Each table is contain user id .
some situation i just need to get value from the contact table or some other situation may be from two table.But display page is same only.
你真的没有告诉我们很多。但是,它可能是你正在寻找一个JOIN。
如果你有两个表:用户(包含ID,名称,地址)和订单(包含ID,UserID,OrderDate,产品)那么你可以通过JOIN检索相关信息:
You really aren't telling us a lot. But, it may be that you are looking for a JOIN.
If you have two tables: Users (containing ID, Name, Address) and Orders (containing ID, UserID, OrderDate, Product) then you can retrieve the related info with a JOIN:
SELECT u.Name, u.Address, o.Product, o.OrderDate
FROM Users u
JOIN Orders o ON u.ID = o.UserID
WHERE o.OrderDate >= '2016-01-01'
如果那不是什么你正试图这样做,然后你需要给我们一个更多的信息,因为你已经被告知了。
If that isn't what you are trying to do, then you need to give us a whole load more info, as you have alreay been told.
这篇关于从C#中的多个表加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!