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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:42:23+00:00 2026-05-15T07:42:23+00:00

This is my current query – its not getting the required result. I want

  • 0

This is my current query – its not getting the required result. I want it do display all of the “resources” even if they dont have a connection.

SELECT *
FROM (`user_permissions`)
JOIN `user_groups` ON `user_groups`.`id` = `user_permissions`.`role`
JOIN `user_resources` ON `user_resources`.`id` = `user_permissions`.`resource`
WHERE `role` = '4'

When I try left join or right join it still returns the same result. The result I get is:

id   | role  | resource | name

5    | 4     |        2 | Changelog 

I want

id   | role  | resource | name

5    | 4    |   2 | Changelog 
null | null | null | Resource2 
null | null | null | Resource3

Is this possible?

  • 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-15T07:42:23+00:00Added an answer on May 15, 2026 at 7:42 am

    Looking through your query, role is part of user_permissions which is one of the connections that may or may not exist. Consider changing your where clause to WHERE `role`= '4' OR `role` IS NULL if you want to display these null records as well…

    Also, although this can be accomplished by a right join, I believe it’s more readable/understandable if you select from user_resources instead, then left join on the other tables. This follows from your problem description statement; you want to “display all of the ‘resources’ even if they don’t have a connection”, which means you want to select from resources, then join on any connections if they exist.

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

Sidebar

Related Questions

If I have a query like this: String Category = HttpContext.Current.Request.QueryString[Product].ToString(); IQueryable<ItemFile> pressReleases =
This is my current query: $sel = SELECT db1t1.userid, db1t1.customer_id, db2t1.customers_id, db2t1.orders_id, db2t2.products_price FROM
My current query looks like this: SELECT * FROM fiberbox f WHERE f.fiberBox LIKE
This is my current query: SELECT DISTINCT t.* FROM filter AS f INNER JOIN
This is my current query: select serial_number, order_number, (select TOP 1 PRODUCT_ID from PS_ORD_LINE
In a trigger I want to see what sql query triggered this trigger. I
I have this query statement and want to only get records that has a
Objective: The intent of this query is to select all of the distinct values
my title may not explain what I am looking for, this is my current
My current query looks like this: SELECT DISTINCT (member), count( UID ) AS numUID

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.