So i have a DB with 3 tables. User Table with U_ID
and U_Name
, Class with C_ID
, and C_Name
and User_Class Table with U_ID
and C_ID
. Foreign keys are set.
I want to display the classes associated with the selected user. The user is identified by their name. I know these are the two SQL statements I need to execute:
SELECT U_ID FROM User WHERE U_Name = current_U_name
then
SELECT C_ID FROM User_Class WHERE U_ID = current_U_ID
then
SELECT C_Name FROM Class WHERE C_ID = C_IDforAllMatchingRows
I wanted to use a dataset to store the results of each statement but I could not figure out how to access one value in the dataset i.e.
(SELECT C_ID FROM User_Class WHERE U_ID = *dataset.Tables(0).Column(0)*)
- does not work
I started using gridviews because i could access the values stored in each cell like above.
I must be missing a simple way to retrieve the information i need from these three simple tables.
Any help is appreciated, thanks