October 27, 2015 at 11:13 pm
CREATE TABLE [dbo].[Managements](
[ManagementId] [int] NOT NULL,
[FTAManagementNo] [varchar](35) NULL
)
CREATE TABLE [dbo].[MgmtCountries](
[MgmtCountryId] [int] not null,
[CountryId] [int] null,
[ManagementId] [int] null ,
[FTAManagementNo] [varchar](35) NULL
)
i want to get only those ManangementId which is available in MgmtCountries table with countryid=19
Conditions: 1. Get MangementId only if countryid matched
2. If record exist in MgmtCountries table with another countryid then dont return MangementId
3. If Record does not exist in MgmtCountries table at all the return MangementId
October 28, 2015 at 1:14 am
shkoli (10/27/2015)
CREATE TABLE [dbo].[Managements]([ManagementId] [int] NOT NULL,
[FTAManagementNo] [varchar](35) NULL
)
CREATE TABLE [dbo].[MgmtCountries](
[MgmtCountryId] [int] not null,
[CountryId] [int] null,
[ManagementId] [int] null ,
[FTAManagementNo] [varchar](35) NULL
)
i want to get only those ManangementId which is available in MgmtCountries table with countryid=19
Conditions: 1. Get MangementId only if countryid matched
2. If record exist in MgmtCountries table with another countryid then dont return MangementId
3. If Record does not exist in MgmtCountries table at all the return MangementId
Select ManagementId
from dbo.Managements m
where not exists (select 1 from dbo.MgmtCountries mc where mc.CountryId <> 19 and mc.ManagementId = m.ManagementId)
If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply