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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:26:39+00:00 2026-06-11T18:26:39+00:00

I need to convert the following two working queries into a single query but

  • 0

I need to convert the following two working queries into a single query but everything
I try just dies on me for various reasons. My end result is to try to list all
software on hand, and show which software is installed and which is not installed for the specific PC being queried. For installed software, list the name, otherwise show NULL for the name. I’ve tried some sub-select statements in the where clause which gave me a result without an error, but not the right result. Any help is appreciated.

qry1

SELECT device_software.sw_id

FROM Software_device LEFT JOIN Device ON Software_device.d_id = Device.d_id

WHERE Device.d_id = 1;

qry2

SELECT Software.name, Software.sw_id, qry1.sw_id

FROM software LEFT JOIN qry1 ON software.sw_id = qry1.sw_id;

Device Table

------------------
| name  | d_id  |
------------------
| PC1   | 1     |
| PC2   | 2     |
| PC3   | 3     |
------------------

Software Table

------------------
| name  | sw_id |
------------------
| SW_a  | A     |
| SW_b  | B     |
| SW_c  | C     |
| SW_d  | D     |
------------------

Software_Device Table (Many-to-many)

------------------
| d_id  | sw_id |
------------------
| 1     | A     |
| 1     | B     |
| 2     | A     |
| 2     | B     |
| 2     | C     |
------------------

Result Im looking for…
(Installed AND uninstalled software on PC1)

---------------------------------
| Sotfware  | pc_id |   name    |
---------------------------------
| SW_a      | 1     |   PC1     |
| SW_b      | 1     |   PC1     |
| SW_c      | NULL  |   NULL    |
| SW_d      | NULL  |   NULL    |
---------------------------------

I listed both mysql and sql tags because I don’t think it matters, but just in case it does, i’m using mysql.

  • 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-11T18:26:40+00:00Added an answer on June 11, 2026 at 6:26 pm

    If RomanKonz answer is definitely close, just move the “where” to “on”, letting the left join work appropriately.

    select software.name as Software,
        device.d_id as pc_id,
        device.name as name
    from software
        left join device_software
            on device_software.sw_id = software.sw_id
           and **device_software**.d_id = 1
        left join device
            on device_software.d_id = device.d_id
    ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to convert all of the following forms into .NET Uri object: hello.world
I need to convert a Joda-Time DateTime into a String, in the following format:
I need to convert a time difference (diff) between two actions into a human
I need to convert a column data into single row with multiple columns Example
I have the following two queries: $query = $this->doctrine->em->createQuery(select u from ORM\Dynasties2\Characters u WHERE
I need to convert the following java method to scala and am having difficulty
I have the following int 7122960 I need to convert it to 71229.60 Any
I have the following FORTRAN code which I need to convert to C or
I need to compare two dates with time (am/pm). I used the following code.
I am trying to convert the following SQL into NHibernate: SELECT * FROM dbo.Customer

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.