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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:51:28+00:00 2026-06-17T03:51:28+00:00

I have two tables as below. user_id | username | first_name | role_type ———————————————————–

  • 0

I have two tables as below.


user_id   |   username        |  first_name |   role_type
-----------------------------------------------------------
1         |   testuser1       |  testu1     |    student
2         |   testuser2       |  testu2     |    student
3         |   testuser3       |  testu3     |    student
4         |   testuser4       |  testu4     |    student
5         |   testuser5       |  testu5     |    student
6         |   testuser6       |  testu6     |    admin
7         |   testuser7       |  testu7     |    admin
-----------------------------------------------------------

user_id   |   username         |    approved_id
----------------------------------------------------------------------
1         |   testuser1        |  3B888F52-50BC-11E2-B08B-99E5B2CADDF7
2         |   testuser2        |  3B888F52-50BC-11E2-B08B-99E5B2CADDF7
3         |   testuser3        |  3B888F52-50BC-11E2-B08B-99E5B2CADDF7
----------------------------------------------------------------------

I tried the query

SELECT users.* FROM users 
WHERE users.username NOT IN(
     SELECT users_approval.username FROM users_approval 
     WHERE users_approval.approved_id = "3B888F52-50BC-11E2-B08B-99E5B2CADDF7"
) AND users.role_type = "student"

and got the result below


user_id   |   username        |  first_name |   role_type
-------------------------------------------------------------
4         |   testuser4       |  testu4     |    student
5         |   testuser5       |  testu5     |    student
-------------------------------------------------------------

Is there any way to use JOIN to fetch the same resultset as above ?.

Help is much appriciated.

  • 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-17T03:51:30+00:00Added an answer on June 17, 2026 at 3:51 am
    SELECT users.* 
    FROM   users 
           LEFT JOIN users_approval b
              ON users.username = b.username AND
                 b.approved_id = "3B888F52-50BC-11E2-B08B-99E5B2CADDF7"
    WHERE  users.role_type = "student" AND
           b.approved_id IS NULL
    
    • SQLFiddle Demo
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables described below. What I need is a single query that
I'm using SQL Server 2008. Let's say I have two hypothetical tables like below:
I have two tables like the ones below. I need to find what exchangeRate
I have two tables names book_list and book_category . Schema is like below: book_list
I have created two tables & inserted values as shown below . Table 1
I have 10 tables in my database(MySQL). two of them is given below tbl_state
I am have two tables which I have left joined like so below to
so I have two tables. They are pictured below. I have a master table
When I have the below two tables, would the StatusTypes table be considered as
I have two data tables. One contains all of users identifiable informaiton (username, id,

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.