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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:35:35+00:00 2026-05-28T00:35:35+00:00

I wanna know a single MySQL query for solving this problem: I have a

  • 0

I wanna know a single MySQL query for solving this problem:

I have a table that consists of member ids and location ids..

_________________________________________________________
|      |                        |                        |
| ID   |  Member Id             |       Location         |
|______|________________________|________________________|
|      |                        |                        |
| 1    |    2371                |           7            |
|      |                        |                        |
| 2    |    5123                |          10            |
|      |                        |                        |
| 3    |    2371                |           9            |
|      |                        |                        |
| 4    |    5123                |           9            |
|      |                        |                        |
| 5    |     565                |           9            |
|      |                        |                        |
| 6    |    2371                |           5            |
|      |                        |                        |
| 7    |    5123                |           6            |
|      |                        |                        |
|______|________________________|________________________|

Another table consists of all the locations data:

__________________________________________________
|                        |                        |
|  Location Id           |       Location Name    |
|________________________|________________________|
|                        |                        |
|      1                 |           ABC          |
|                        |                        |
|      2                 |           BCD          |
|                        |                        |
|      3                 |           CDE          |
|                        |                        |
|      4                 |           DEF          |
|                        |                        |
|      5                 |           EFG          |
|                        |                        |
|      6                 |           GHI          |
|                        |                        |
|      7                 |           HIJ          |
|                        |                        |
|      8                 |           IJK          |
|                        |                        |
|      9                 |           JKL          |
|________________________|________________________|

I wanna find all location ids from the table where member id 2371 is not present. How can I find this in single query? I know I can do it if I break the query into two pieces.. Like array of all locations.. and array of all locations where member id exist. Then using !in_array function of PHP

Thanks for your time and help in advance.

  • 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-28T00:35:36+00:00Added an answer on May 28, 2026 at 12:35 am

    You can find all locations that member 2371 is in by doing:

    SELECT location 
    FROM memberlocation
    WHERE memberid = 2371
    

    You can find all other locations (the ones you want) by:

    SELECT * 
    FROM location 
    WHERE locationid NOT IN 
        ( SELECT location 
          FROM memberlocation
          WHERE memberid = 2371)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Have a data template that i use in items control, i wanna know
Alright, I wanna know why this code is working, I just realized that I
I wanna know if this is possible. I have an external .css file in
i have a problem with db4o and I wanna know is it feature or
I wanna know that how we can identify whether a page is redirecting to
I am developing a software with vb6.0 :( . I wanna to know that
So, that´s what I wanna know. How can I set the visibility of the
i have a client server application, the server uses nhibernate. i wanna know how
As mentioned in title. I wanna know that does SQL Server can partially execute
I've 1 line AppleScript, I wanna know what does this AppleScript do? do shell

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.