Hi all,
I have a problem achieving the result. I want data as below which is based on 4 tables
Expected rasult
SiteID SiteName State PostCode Phone1 StateName CanDelete
---------------------------------------------------------------------------------
1 Site1 1 2134 124 123 - ADC 1
2 Site2 3 2323 124 234 - QTY 0
3 Site3 5 7666 124 645 - LDG 0
4 Site4 2 2888 124 894 - WA 1
And the tables are as below
tbl_site
SiteID SiteName State PostCode Phone1
-------------------------------------------------------
1 Site1 1 2134 124 123
2 Site2 3 2323 124 234
3 Site3 5 7666 124 645
4 Site4 2 2888 124 894
tbl_state
StateID StateName
------------------------
1 ADC
2 WA
3 QTY
4 RKH
5 LDG
tbl_trial_site
TrialID SiteID
---------------------
1 1
tbl_user_site
UserID SiteID
---------------------
1 4
And the senario is the CanDelete column should be 1 if SiteID has references in any of the 2 tables (tbl_trial_site, tbl_user_site) it should be zero if non of the 2 tables has a reference to SiteID
Can any one please help me as i'm new to SQL and in greate need for help.
Thank you for your valuable time.