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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:56:54+00:00 2026-06-05T22:56:54+00:00

I have a MySQL table called accounts . Within this table is a field

  • 0

I have a MySQL table called accounts. Within this table is a field called salesmanager_id. 99% of the time, the value in this field is always the same for all accounts of a specific customer (specified with customer_id).

What I’m trying to do is find the customer_id for the customers that have accounts assigned to more than one salesmanager. For example:

+------------------------------------+
| id | customer_id | salesmanager_id |
|------------------------------------|
| 1  | 12          | 4               |
| 2  | 12          | 4               |
| 3  | 14          | 3               | <-- I want this customer_id
| 4  | 14          | 4               |
+------------------------------------+

In the above example, customer_id 14 has both salesmanager_id 3 and 4 assigned to it. I would like to retrieve that customer_id for my list.

I tried the following query, but that returns an empty result (while I’m sure there are at least some differences).

SELECT `name`, `customer_id` AS `customer`, `salesmanager_id` FROM `accounts`
WHERE `salesmanager_id` NOT IN (
    SELECT `salesmanager_id` FROM `accounts` a
    LEFT JOIN `customers` c ON (a.customer_id = c.id)
    WHERE a.customer_id=c.id
) GROUP BY `customer`;
  • 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-05T22:56:55+00:00Added an answer on June 5, 2026 at 10:56 pm
    SELECT 
        customer_id
    FROM 
        accounts
    GROUP BY 
        customer_id
    HAVING 
        COUNT(DISTINCT salesmanager_id) > 1
    

    This basically gets all of the salesmanager_ids of each customer_id and if there is more than one unique salesmanager_id value, the customer_id is returned.

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

Sidebar

Related Questions

$value = 'http://www.mydomain.com/this-is-page-one' I have a field in my mysql table called urls which
I have this mysql table called comments which looks like this: commentID parentID type
I have a MySQL database table called Participant that looks something like this: (idParticipant)
Hi I have a field in mySql table called jobnumber which auto increments with
I have a MySQL table called privatemessage with a primary key field called messageid.
Suppose I have a MySQL table called MyTable, that looks like this: +----+------+-------+ |
I have a MySQL database table called submission with a field called points with
I have a mysql table called RATING with this structure: ID, USERNAME, RATING, RATER,
I have a date and time column in my mysql table called start_date and
I have a mysql table with a field called POSTIDS POSTIDS values: 1,2,6,7,15,24,25,63,78,98,120 I

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.