Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9029039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:09:10+00:00 2026-06-16T07:09:10+00:00

I have the following schema and related data. — Schema CREATE TABLE [PERSON] (

  • 0

I have the following schema and related data.

-- Schema
CREATE TABLE [PERSON] (
    [id] int NOT NULL,
    [first_name] varchar(50) NOT NULL,
    [last_name] varchar (50) NOT NULL
    CONSTRAINT [PK__PERSON] PRIMARY KEY ([id])
) 
GO

CREATE TABLE [EVENT] (
    [id] int NOT NULL,
    [name] varchar(50) NOT NULL
    CONSTRAINT [PK__EVENT] PRIMARY KEY ([id])
)
GO

CREATE TABLE [EVENT_PARTICIPANT] (
    [event_id] int NOT NULL,
    [person_id] int NOT NULL
    CONSTRAINT [PK__EVENT_PARTICIPANT] PRIMARY KEY ([event_id], [person_id])
)
GO

ALTER TABLE [EVENT_PARTICIPANT] ADD CONSTRAINT [FK__EVENT__EVENT_PARTICIPANT__event_id]
    FOREIGN KEY ([event_id])
    REFERENCES [EVENT]([id])
GO

ALTER TABLE [EVENT_PARTICIPANT] ADD CONSTRAINT [FK__PERSON__EVENT_PARTICIPANT__person_id]
    FOREIGN KEY ([person_id])
    REFERENCES [PERSON]([id])
GO

-- data
INSERT INTO [PERSON] VALUES(1, 'Alpha', 'A')
INSERT INTO [PERSON] VALUES(2, 'Bravo', 'B')
INSERT INTO [PERSON] VALUES(3, 'Charlie', 'C')
INSERT INTO [PERSON] VALUES(4, 'Delta', 'D')
INSERT INTO [PERSON] VALUES(5, 'Echo', 'E')
INSERT INTO [PERSON] VALUES(6, 'Foxtrot', 'F')
INSERT INTO [PERSON] VALUES(7, 'Golf', 'G')
INSERT INTO [PERSON] VALUES(8, 'Hotel', 'H')
INSERT INTO [PERSON] VALUES(9, 'India', 'I')
INSERT INTO [PERSON] VALUES(10, 'Juliet', 'J')
GO

INSERT INTO [EVENT] VALUES(1, 'Event A')
INSERT INTO [EVENT] VALUES(2, 'Event B')
INSERT INTO [EVENT] VALUES(3, 'Event C')
INSERT INTO [EVENT] VALUES(4, 'Event D')
INSERT INTO [EVENT] VALUES(5, 'Event E')
INSERT INTO [EVENT] VALUES(6, 'Event F')
INSERT INTO [EVENT] VALUES(7, 'Event G')
INSERT INTO [EVENT] VALUES(8, 'Event H')
INSERT INTO [EVENT] VALUES(9, 'Event I')
INSERT INTO [EVENT] VALUES(10, 'Event J')
GO

INSERT INTO [EVENT_PARTICIPANT] VALUES(1,1)
INSERT INTO [EVENT_PARTICIPANT] VALUES(1,2)
INSERT INTO [EVENT_PARTICIPANT] VALUES(1,3)
INSERT INTO [EVENT_PARTICIPANT] VALUES(2,4)
INSERT INTO [EVENT_PARTICIPANT] VALUES(2,5)
INSERT INTO [EVENT_PARTICIPANT] VALUES(2,6)
INSERT INTO [EVENT_PARTICIPANT] VALUES(3,5)
INSERT INTO [EVENT_PARTICIPANT] VALUES(3,6)
INSERT INTO [EVENT_PARTICIPANT] VALUES(4,1)
INSERT INTO [EVENT_PARTICIPANT] VALUES(4,4)
INSERT INTO [EVENT_PARTICIPANT] VALUES(5,1)
INSERT INTO [EVENT_PARTICIPANT] VALUES(6,7)
INSERT INTO [EVENT_PARTICIPANT] VALUES(7,8)
INSERT INTO [EVENT_PARTICIPANT] VALUES(8,9)
GO

I need to find all the conflicting events where there are matching participants such that the query returns for each event a list of events conflicting with it. The matching does not have to be 100% Even if one person matches, that means the events are conflicting with each other.

I’ve already generated a comma separated list of event participants for each event, but struggling a little with how to write an efficient query to get the conflicting event for SQL Server 2008.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T07:09:11+00:00Added an answer on June 16, 2026 at 7:09 am

    You could try with this query:

    select distinct ep1.event_id,ep2.event_id
    from EVENT_PARTICIPANT ep1
    inner join EVENT_PARTICIPANT ep2 on ep1.person_id=ep2.person_id
    where ep1.event_id <> ep2.event_id
    order by 1,2

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 3 tables with the following schema: CREATE TABLE `devices` ( `device_id` int(11)
I have the following pseudo-SQL schema: table flight id int primary key date timestamp
I have a table name Discount that has the following schema: PK DiscountID int
I have the following schema, which I've simplified slightly: CREATE TABLE [dbo].[Header] ( [HeaderId]
I have the following DB Schema :- Data is ... Location Table 1. New
I have the following schema, which I use to ensure that a person's PhoneNumber
I have a bunch of coordinates in my table grid with the following schema
I have the following Execution statement which creates a table (using data from another
Suppose I have the following schema t = {name: 'John', reviews: [{sid: 1, comment:
I have the following XML Schema: <Root> <EventSet> <Event> <id> //random id </id> <time>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.