Click here to Skip to main content
15,890,336 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have three table [tbl_user, tbl_controls, tbl_link],
tbl_user
UserID
UserName

tbl_controls
C_ID
ControlName

tbl_link
lk_id
UserID
C_ID
Status (bit)

the control is placed in the tbl_control, and assign control status is placed in tbl_link, I want to load app control in a grid view but the relevant status is marked tick by the reference of UserID.

How i accomplished this.

THanks
Regards

What I have tried:

SELECT        tbl_controls.ControlName, tbl_link.Status
FROM            tbl_controls left outer JOIN
                         tbl_link ON tbl_controls .C_ID= tbl_link .C_ID
WHERE        (tbl_link.Status IN
                             (SELECT        Status
                               FROM           tbl_link AS tbl_link_1
                               WHERE        (UserID= 30)))
Posted
Updated 1-Oct-18 23:48pm

1 solution

I'm not sure i understand you well, but... try this:
SQL
SELECT TC.ControlName, TL.Status
FROM tbl_link AS TL
    INNER JOIN tbl_user AS TU ON TL.UserID = TU.UserID
    INNER JOIN tbl_controls AS TC ON TL.C_ID = TC.C_ID
WHERE TL.USerId =30


For further details, please see: Visual Representation of SQL Joins[^]
 
Share this answer
 
Comments
RASHID ALI786 3-Oct-18 3:07am    
Hi,
Maciej Los.
Thanks for the reply.
But the thing i want to accomplish is that,
All record in the Control table display along with status and based on user id status shows true for those controls that are assigned to the user.

Hope you understand what i am trying to say.

Thanks for the help.
Maciej Los 3-Oct-18 3:14am    
Does above query does not meet your criteria? Have you tested it?
RASHID ALI786 9-Dec-18 11:25am    
yes i do, but nothing happend

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