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 6153719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:08:23+00:00 2026-05-23T20:08:23+00:00

I have two tables one called meeting and one called attendance, attendance is a

  • 0

I have two tables one called meeting and one called attendance, attendance is a many to many relational database in the following format:

Attendance:
    user_id | meeting_id | invited
    --------+------------+--------
    1       | 5          | 1
    2       | 5          | 0
    3       | 4          | 0
    3       | 5          | 1
    3       | 6          | 0

Meetings are in the following format:

Meetings:
    meeting_id | meeting_name | owner_id
    -----------+--------------+----------
    3          | Awesome      | 2
    4          | Boring       | 2
    5          | Cool         | 5
    9          | Sexy         | 3

There can only be one meeting row per meeting, but unlimited attendance rows per meeting (limited to for every possible user for every meeting).

How in SQL and/or Propel do I create something that would list all meetings where the (provided) user_id is either the owner_id in meetings OR were the user_id and invited in the attendance database.

I am looking for a result (based on the above data) when searching for userid 3 of:

Result for userid3:
    meeting_id | meeting_name | owner_id
    -----------+--------------+----------
    5          | Cool         | 5     - Because userid 3 is attending meeting 5
    9          | Sexy         | 3     - Because userid 3 owns meeting 9

I currently have the following which doesn’t work really, and produces multiple rows per meeting (because the meeting exists more than once in the attendance DB).

$criteria->addJoin(MeetingMeetingsPeer::ID, MeetingAttendancePeer::MEETING_ID, Criteria::LEFT_JOIN);

$criterion = $criteria->getNewCriterion(MeetingMeetingsPeer::OWNER_ID, Meeting::getUserId());
$criterion->addOr($criteria->getNewCriterion(MeetingAttendancePeer::USER_ID, Meeting::getUserId()));

$criteria->add($criterion); 
return $criteria;

Which is something like the below in SQL:

SELECT meeting_meetings.ID, meeting_meetings.OWNER_ID, meeting_meetings.GROUP_ID, meeting_meetings.NAME, meeting_meetings.COMPLETED, meeting_meetings.LOCATION, meeting_meetings.START, meeting_meetings.LENGTH, meeting_meetings.CREATED_AT, meeting_meetings.UPDATED_AT FROM `meeting_meetings` LEFT JOIN meeting_attendance ON (meeting_meetings.ID=meeting_attendance.MEETING_ID) WHERE (meeting_meetings.OWNER_ID=1 OR meeting_attendance.USER_ID=1) 

Thanks for your time,

  • 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-05-23T20:08:24+00:00Added an answer on May 23, 2026 at 8:08 pm

    This should get you all meetings that are owned by user_id 1, as well as all meetings that are attended by user_id 1.

    SELECT meeting_meetings.ID, meeting_meetings.OWNER_ID, meeting_meetings.GROUP_ID, meeting_meetings.NAME, 
    meeting_meetings.COMPLETED, meeting_meetings.LOCATION, meeting_meetings.START, meeting_meetings.LENGTH, 
    meeting_meetings.CREATED_AT, meeting_meetings.UPDATED_AT 
    FROM `meeting_meetings`
    WHERE `meeting_meetings`.`owner_id` = 1
    UNION DISTINCT
    SELECT meeting_meetings.ID, meeting_meetings.OWNER_ID, meeting_meetings.GROUP_ID, meeting_meetings.NAME, 
    meeting_meetings.COMPLETED, meeting_meetings.LOCATION, meeting_meetings.START, meeting_meetings.LENGTH, 
    meeting_meetings.CREATED_AT, meeting_meetings.UPDATED_AT 
    FROM `meeting_meetings`
    JOIN `meeting_attendance` ON `meeting_meetings`.`meeting_id` = `meeting_attendance`.`meeting_id` AND `meeting_attendance`.`invited`
    WHERE `meeting_attendance`.`user_id` = 1
    

    It’s a bit clunky. Personally, I would consider adding an owner flag to the meetings_attendance table.

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

Sidebar

Related Questions

I have two tables: one called Projects, and another called Documents (projects has many
I have two tables on my database. One called room and another is called
I have two tables. One of them called conversations has the following data. ConversationID
I have two tables in my database. The first one, [nodeActivity] has the following
I have two tables one called fs_note the other called dumy_fs_note I created after
i have two tables one is called addons and holds information about different addons,
I have two tables, one called cart and one called items. Now I want
So i'm having this problem. I have two tables (Oracle), one is called Destination
I have two tables connected with one to many relationship. Parent Table is a
I have two tables, one called countries and one called country. Countries has both

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.