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

  • Home
  • SEARCH
  • 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 8176163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:03:28+00:00 2026-06-06T23:03:28+00:00

i am curetly building a cms, I have a tables called menus Menus MenuID

  • 0

i am curetly building a cms,
I have a tables called menus

Menus

MenuID | MenuName
1        Home
2        users
3        email
4        system

i have another table to control user access to these menus

call user_menu_access
MenuID | UserID
1           1
2           1

i am doing a left join like this

SELECT * 
FROM menus
LEFT JOIN user_menu_access 
    ON menus.MenuID = user_menu_access.MenuID 
WHERE UserID = 1

my result set dublicates rows as i will have to enties for 1 and 2 , i want to
have a result set that is as follows

MenuID  | UserID
1           1
2           1
3           NULL
4           NULL
  • 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-06T23:03:30+00:00Added an answer on June 6, 2026 at 11:03 pm

    You need to move the condition into the ON clause:

    SELECT menus.menuid, userid 
    FROM menus
    LEFT JOIN user_menu_access 
        ON menus.MenuID = user_menu_access.MenuID 
        AND UserID = 1
    

    See this query executing (giving exactly the results you asked for) here.

    The reason this works is that the WHERE clause filters the rowset after the join has occurred, but because you’re doing a left join, the columns of the user_menu_access table are all null for menus that don’t have any user access, so your condition isn’t true for those rows.

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

Sidebar

Related Questions

I'm currently working on a home-made full front-office 100% javascript CMS of ours, and
How do i add these sections to certificate (i am manualy building it using
I have an object that is curently being serialized to: { label : label,
I have a function foo that takes a NxM numpy array as an argument
curently I have this for HTML and CSS respectively:.....How would I contruct CSS and
I have a call to a model which is just a standard class (not
I am of the PHP background and just have started to learn Django and
Nothing is currently broken. :) I'm just looking to gain some performance. I have
i curently try to make a search for my system using $_GET so when
I'm writing a Lisp to C translator and I have a problem with handling

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.