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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:57:38+00:00 2026-06-06T07:57:38+00:00

I have a database that has 16 tables, but only four are relevant to

  • 0

I have a database that has 16 tables, but only four are relevant to this. The database tracks different servers, the servers information (CPU, RAM, IP Address, etc) and the software it is running. The software and machines are related through a join table.

CREATE TABLE machsoftjt (
     mid int(4) NOT NULL,
     sid int(4) NOT NULL,
     slid int(4) NOT NULL,
     notes varchar(255) default NULL,
     UNIQUE KEY mid (mid,slid)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

mid is the machine’s id from the machines table, sid is the software’s id from the software table which contains the software’s name and software’s version, slid is the softwarelist id from the softlist table(a table with just lists the software being run and is used for unique constraint so that when software upgrades are performed I don’t have an entry for one machine running two different versions of the same software). So if I have machine1 (with a mid of 1) running Microsoft Word 2010 (with a sid of 1 and a slid of 1) and Adobe Photoshop 5 (with a sid of 2 and a slid of 2), the table would have

mid  sid   slid
1    1     1
1    2     2

I want to select from this table all machines that is running both Microsoft Word and Adobe Photoshop.

SELECT machines.machinename FROM (machines INNER JOIN machsoftjt ON 
  machines.mid=machsoftjt.mid) INNER JOIN software ON machsoftjt.sid=software.sid
  WHERE machsoftjt.slid='1' AND machsoftjt.slid='2'

When I run this query, I do not get anything backWhen I run this query, I do not get anything back. And I am now stumped and can’t come up with anything else. All help would be greatly appreciated.

  • 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-06T07:57:40+00:00Added an answer on June 6, 2026 at 7:57 am

    This calls for a self-join. Roughly:

    SELECT machines.machinename 
    FROM machines 
    INNER JOIN machsoftjt AS m1 ON machines.mid=m1.mid 
    INNER JOIN machsoftjt AS m2 ON machines.mid=m2.mid 
    WHERE m1.slid='1' AND m2.slid='2'
    

    To get software names, roughly:

    SELECT machines.machinename, s1.*, s2.*
    FROM machines 
    INNER JOIN machsoftjt AS m1 ON machines.mid=m1.mid 
    INNER JOIN machsoftjt AS m2 ON machines.mid=m2.mid 
    INNER JOIN software s1 ON m1.sid=s1.sid
    INNER JOIN software s2 ON m2.sid=s2.sid
    WHERE m1.slid='1' AND m2.slid='2'
    

    You’ll probably have to alias the relevant columns from s1 and s2

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

Sidebar

Related Questions

I have a SQL database that has several hundred tables in it, but I
I have a database that has four columns like this level_1, level_2, level_3, level_4
I have a database that has node & nodetype tables. Nodes table NodeID ParentNodeID
I have a Content Provider for a SQLite database that has multiple tables and
I have a relatively large database tables (just under a million rows) that has
I have an application in mind which dicates database tables be append-only; that is,
Consider this: One mySQL database that has tables and rows and data within it.
I have a SQL database that has a table with a field set to
I have a database table that has a structure like the one shown below:
I have a database table that has a Unique Key constraint defined to avoid

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.