Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 30-Oct-16 4:45am
v2
Comments
OriginalGriff 30-Oct-16 7:09am    
You're going to have to give us better information that that: we don't have any access to your database, we can't see your screen, we can't access your HDD. So we have no idea what any relationship between the tables might be, what you are trying to retrieve, or what you are trying to do with it.
Use the "Improve question" widget to edit your question and provide better information.
Member 12823631 30-Oct-16 7:15am    
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.
Rahul VB 30-Oct-16 10:54am    
I think each "Table" is having information about the user.
Ok, so as per my translation, for every single user there are multiple tables.
Lets say there are Tables :- T1, T2, T3 ..... and so on.
T1 will contain contact information, T2 address details and T3 will contain something else.
In some of the scenarios you want the contact of the user lets say from "T1". In an other scenario you want address details from "T2".
And, all of this information/Tables should be one a single page.

If this is our common understanding please update your question, so that next time no one else has to face such difficulty.

So, do you feel you have redundant tables?
If you confirm, only then can we engineer some solution.

Member 12823631 31-Oct-16 3:22am    
above mention table structure is what i am having .
for Ex: username is XXXXXX,
T1 is storing Name deatils(midilename,surname.familyname etc..)
T2 is having Contact info of same user (phone,email etc..)
like this T3,T4,.T10.

sometime i need all this 10table info in one aspx page.
some time i need only 3 table info.
sometime i need only 1 table info.

is it better in one sp loading all info
or 10 different sp ??
Rahul VB 31-Oct-16 6:05am    
I would suggest having one table containing all the information (Contact, Address, Family etc) for a single user. In fact you can have this for multiple users.
Example:
User ID | Name | Contact | Address | Email
1 ABC 123 H1 gmail

and so on. I dont understand the use of multiple tables when it can be done it one.
Try to create views based on your priority and filter data from them.




1 solution

Quote:
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.

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:
SQL
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.
 
Share this answer
 
Comments
Member 12823631 31-Oct-16 2:00am    
I just need a better way to show a user details in one aspx page.The criteria is sometimes no need to show all info.only contact info.sometimes only adress like this ..As i mentioned before there are 10 + tables(each table have 6 columns mini). Is it better to write 10 stored procedure and call which one we need Or all Query write in one stored procedure and show the result.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900