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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:28:06+00:00 2026-05-23T05:28:06+00:00

-Goal- I would like to fetch users who do not have an entry within

  • 0

-Goal-

I would like to fetch users who do not have an entry within the ‘bar’ table. These users will also belong to a certain ‘usergroup’ and have restrictions within the ‘user’ table itself.

Simplified table structure

User

userid - auto-increment    
username - string    
userage - integer    
usergroup_usergroupid - foreign key

usergroup

usergroup - auto-increment    
usergroupname - string

user_has_bar

user_userid - foreign key    
bar_barid - foreign key

-Query…so far-

SELECT username     
FROM user as u, usergroup as ug, user_has_bar as ub    
WHERE    
u.usergroup_usergroupid = ug.usergroupid AND    
u.userage = 10 AND  <-- lets pretend this exists    
u.location_locationid = 1 AND <-- Same here     
u.userid ... ub.user_userid;

-Headache-

It is this last line that has me throwing up blanks. I believe from what I have read up on, the way to perform this operation is with a LEFT JOIN. However, everything i have read so far ends up being quite confusing.

If possible, I would like to keep this operation within a mySQL query and then optimise later.It is created by a PHP mySQL generator I coded and I would like to understand the simple syntax and then dig more in to it. Any approach is VERY welcome though

Thank you kindly for reading this question.

  • 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-23T05:28:07+00:00Added an answer on May 23, 2026 at 5:28 am
    SELECT username
        FROM user u
            INNER JOIN usergroup ug
                ON u.usergroup_usergroupid = ug.usergroupid 
            LEFT JOIN user_has_bar ub
                ON u.userid = ub.user_userid
        WHERE u.userage = 10
            AND u.location_locationid = 1
            AND ub.user_userid IS NULL
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My Goal I would like to have a main processing thread (non GUI), and
I would like to have a Maven goal trigger the execution of a java
I would like to rewrite the collection that is returned by Mage::getResourceModel('sales/order_collection'); My goal
I have about 30 different flagged enums that I would like to put into
Here is my goal: I would like to be able to report various metrics
I have this application with which I would like to store about 50MB of
I have a random 2D image. I would like to be able to present
I would like to develop an application with two languages. Actually, the goal is
My goal I would like to let browsers cache my whole website, but only
I have one need: In an Asp.Net 4.0 application I would like to deny

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.