help with sql syntax

vanillathunder722

Active Member
Joined
Jan 14, 2011
Messages
66
Reaction score
0
Location
durban
I made a program using c# windows form where user can enter their details such as club name and their own personal detail such as their age etc.
basically i created two tables, club and client.

now i would like to display them using one gridview.
i would like to know what's the error with the sql statement

DataSet ds = useDb.Query("SELECT club.ID, club.clubName FROM [club] JOIN [client] ON client.clubID = club.ID", "club");
DataTable dt = ds.Tables["club"];
 
"SELECT club.ID, club.clubName FROM [club] JOIN [client] ON client.clubID = club.ID"
should be
"SELECT club.ID, club.clubName FROM [club] inner JOIN [client] ON client.clubID = club.ID"
 
Bad database design just FYI.

A person tends to go to more than 1 club (variety being the spice of life and all that ****). So what you'll end up with (following what you did) is duplicate entries for the same person (client) per club they visited.

Better design would be:

Club_Table (clubid,clubname etc)
Client_Table (clientid,name,age,sexy sex etc)
ClientClub_Table (clientid,clubid)

Then you can add as many clubs to a client as you'd like without running the risk of having "John Smith, age 32" pop up 60 times because he frequents 60 clubs. It will allow you to get rid of the nightmare it will cause data-maintenance wise down the line and even if this is only used for 1 club, by doing what I suggested you open up the program to be more flexible and allow for different clubs with the same members. You can then do different reports to determine which type of clubs a person likes (since you know that "John Smith likes to go to x y and z clubs" and then do **** like, promote a new club to those guys in those areas. You'd get info on which areas people frequent as well... and then be able to sell that data to people looking to investigate the potential of opening a new club/restaurant/whatever in that area etc etc etc etc etc etc... fun stuff when you do it right the first time around :D
 
Top
Sign up to the MyBroadband newsletter
X