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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:29:41+00:00 2026-05-24T02:29:41+00:00

Background: my employer has a database powered by a really old version of MySQL

  • 0

Background: my employer has a database powered by a really old version of MySQL (3.23). I have been asked to find duplicate serial numbers and MAC addresses in the database.

I was able to find the duplicate serial numbers, but since this version of MySQL doesn’t support subqueries, I had to resort to using a temporary table. These are the two SQL statements I ended up using:

CREATE TEMPORARY TABLE IF NOT EXISTS Inventory_Duplicate_Serials
SELECT Serial
FROM Inventory
WHERE Serial IS NOT NULL
GROUP BY Serial
HAVING COUNT(Serial) > 1

SELECT DeviceName, Model, Inventory.Serial
FROM Inventory
INNER JOIN Inventory_Duplicate_Serials
ON Inventory.Serial = Inventory_Duplicate_Serials.Serial
ORDER BY Serial

Now I need to find the duplicate MAC addresses. The problem is the “Inventory” table has three MAC address fields (MAC, MAC2, and MAC3). So, for example, if the value of an item’s “MAC” field is the same as the value of another item’s “MAC2” field, I need to know about it. How do I go about doing this? Thank you for your time.


UPDATE: Solved. I ended up creating two temporary tables (Inventory_All_MACs and Inventory_Duplicate_MACs). These are the five queries:

CREATE TEMPORARY TABLE IF NOT EXISTS Inventory_All_MACs
SELECT MAC
FROM Inventory
WHERE MAC != ''

CREATE TEMPORARY TABLE IF NOT EXISTS Inventory_All_MACs
SELECT MAC2 AS MAC
FROM Inventory
WHERE MAC2 != ''

CREATE TEMPORARY TABLE IF NOT EXISTS Inventory_All_MACs
SELECT MAC3 AS MAC
FROM Inventory
WHERE MAC3 != ''

CREATE TEMPORARY TABLE IF NOT EXISTS Inventory_Duplicate_MACs
SELECT MAC
FROM Inventory_All_MACs
GROUP BY MAC
HAVING COUNT(MAC) > 1

SELECT DeviceName, Model, Inventory_Duplicate_MACs.MAC AS DuplicateMAC, Inventory.MAC, MAC2, MAC3
FROM Inventory_Duplicate_MACs
INNER JOIN Inventory
ON Inventory.MAC  = Inventory_Duplicate_MACs.MAC
OR Inventory.MAC2 = Inventory_Duplicate_MACs.MAC
OR Inventory.MAC3 = Inventory_Duplicate_MACs.MAC
ORDER BY Inventory_Duplicate_MACs.MAC, DeviceName, Model

Thanks everybody!

  • 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-24T02:29:42+00:00Added an answer on May 24, 2026 at 2:29 am
    CREATE TEMPORARY TABLE IF NOT EXISTS Inventory_Mac
      SELECT Mac
      FROM Inventory
    
    INSERT INTO Inventory_Mac
      SELECT Mac2
      FROM Inventory
    
    INSERT INTO Inventory_Mac
      SELECT Mac3
      FROM Inventory
    
    CREATE TEMPORARY TABLE IF NOT EXISTS Inventory_Duplicate_Mac
      SELECT Mac, COUNT(*) AS cnt
      FROM Inventory_Mac
      GROUP BY Mac
      HAVING COUNT(*) > 1
    
    
    SELECT DeviceName, Model, im.Mac, i.Mac, i.Mac2, i.Mac3
    FROM Inventory_Duplicate_Mac AS im
      JOIN Inventory AS i
        ON    i.Mac  = im.Mac
           OR i.Mac2 = im.Mac
           OR i.Mac3 = im.Mac
    ORDER BY im.Mac
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background I have been asked by a client to create a picture of the
I have a friend that has been in the advertising industry for 20 years
Background: I have a little video playing app with a UI inspired by the
Background I have a massive db for a SharePoint site collection. It is 130GB
Background I am trying to create a copy of a business object I have
Background I work for a large organization which has thousands of MS Access applications
Through various questions I have asked here and other forums, I have come to
I know this question gets asked a lot because I have looked at many
Background My employer is progressively shifting our resource intensive ETL and backend processing logic
Background The application I am working with has several COM DLLs. One of the

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.