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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:34:20+00:00 2026-06-02T09:34:20+00:00

Sorry, that’s not a very clear title. Here’s what I’ve got: SELECT u.name FROM

  • 0

Sorry, that’s not a very clear title. Here’s what I’ve got:

SELECT u.name 
FROM users u
    INNER JOIN users_permissions
        ON users_permissions.user_id = u.id
        AND users_permissions.permission_id IN ( 1,2 ) 
    LEFT JOIN users_events
        ON users_events.user_id = u.id
        AND users_events.event_id = 3

Ok, so:

Permission “1” lets you edit all events.
Permission “2” only lets you edit certain events, and those events are specified in table users_events.

I want the query result to include only those users who can edit the specified event.

In pseudo-logic, that’s:

where (permission = 1) or (permission = 2 and event = 3)

The query above will include a user with permission “2” (event-specific) even when the list of events they can edit doesn’t include the event I’m checking against.

In essence, I only care about JOINing the users table to the users_events table if the matched permission in the users_permissions table is “2”.

How do I do that? 🙂

  • 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-02T09:34:23+00:00Added an answer on June 2, 2026 at 9:34 am

    You need to use the WHERE clause:

    WHERE perms.permission_id=1 OR (perms.permission_id=2 AND events.event_id=3)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all, sorry about that title. I'm not the best at writing those
Sorry if the title is not that specific, but I don't know how else
First of all sorry that I could not think of a more descriptive title.
I am very sorry that I am not able to provide more details of
Sorry that I haven't done much of my own research but I do not
SORRY:: I forgot that params[:user_id] does not exist in the controller, using current_user.id !
Sorry that I am quite a newbie for Django. So, I got a trouble
[Sorry that English is not my native language.] So, I have a UI and
I'm sorry that I can't find a proper title of my problem. I wrote
First of all, I am sorry that this is not a 'question that can

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.