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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:45:59+00:00 2026-05-31T22:45:59+00:00

I am trying to find the makers of two or more different computers (PC

  • 0

I am trying to find the makers of two or more different computers (PC and/or laptop) with “HD” to be greater than or equal to 10.

Product has: maker & model

both PC & Laptop have: model & HD

This is what I have written so far:

SELECT DISTINCT maker
FROM
    (
        (
            SELECT model, maker
            FROM
            (SELECT model FROM laptop WHERE hd >= 10) AS lap2
            NATURAL JOIN product
        ) as ta
        UNION ALL
        (
            SELECT model, maker
            FROM
            (SELECT model FROM pc WHERE hd >= 10) AS pc2
            NATURAL JOIN product
        ) AS tb
    ) AS t1
    JOIN t1 as t2
    ON (t1.model != t2.model and t1.model > t2.model)

However, it provides me with lovely error:

1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘AS tb ) AS t1 JOIN t1 as t2 ON (t1.model != t2.model and t1.model > t2.model)’ at line 16

EDIT:

Working pieces:

SELECT model, maker
FROM
(SELECT model FROM laptop WHERE hd >= 10) AS lap2
NATURAL JOIN product

SELECT model, maker
FROM
(SELECT model FROM pc WHERE hd >= 10) AS pc2
NATURAL JOIN product
  • 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-31T22:46:00+00:00Added an answer on May 31, 2026 at 10:46 pm

    Since your parentheses are balanced, I don’t think ‘too many parentheses’ is the problem.

    The trouble is at

    JOIN t1 AS t2
    

    You have t1 as the UNION query; you can’t readily also have t1 as a table without confusing everyone.

    You might be able to write:

     JOIN t3 AS t2
    

    where t3 is a table (or view) in the DBMS.

    Incidentally, your ON condition doesn’t need both conditions:

     ON (t1.model != t2.model AND t1.model > t2.model)
    

    It is sufficient to use:

    ON (t1.model > t2.model)
    

    Complex digression

    If you want to do a self-join on the UNION, you will have to write the UNION out twice, or (if MySQL supported it, which I don’t think it does) a CTE (common table expression), aka WITH clause before the main SQL statement:

    WITH t1(model, maker) AS
        (SELECT model, maker
           FROM (SELECT model FROM laptop WHERE hd >= 10) AS lap2
           NATURAL JOIN product
         UNION ALL
         SELECT model, maker
           FROM (SELECT model FROM pc WHERE hd >= 10) AS pc2
           NATURAL JOIN product
        )
    SELECT DISTINCT t1a.maker
      FROM t1 AS t1a
      JOIN t1 AS t1b ON (t1a.model > t1b.model)
    

    I’m not quite sure what the ON condition means; it seems to favour the Zebras over the Aardvarks, but that’s about all. However, that is syntactically (approximately) correct.

    Without the WITH clause, you write the expression out twice:

    SELECT DISTINCT t1a.maker
      FROM (SELECT model, maker
               FROM (SELECT model FROM laptop WHERE hd >= 10) AS lap2
               NATURAL JOIN product
             UNION ALL
             SELECT model, maker
               FROM (SELECT model FROM pc WHERE hd >= 10) AS pc2
               NATURAL JOIN product
           ) AS t1a
      JOIN (SELECT model, maker
               FROM (SELECT model FROM laptop WHERE hd >= 10) AS lap2
               NATURAL JOIN product
             UNION ALL
             SELECT model, maker
               FROM (SELECT model FROM pc WHERE hd >= 10) AS pc2
               NATURAL JOIN product
           ) AS t1b
        ON (t1a.model > t1b.model)
    

    Simple answer

    Of course, this was just an interpretation of your query. Your question seems much simpler:

    SELECT Maker
      FROM (SELECT model, maker
               FROM (SELECT model FROM laptop WHERE hd >= 10) AS lap2
               NATURAL JOIN product
             UNION ALL
             SELECT model, maker
               FROM (SELECT model FROM pc WHERE hd >= 10) AS pc2
               NATURAL JOIN product
           )  AS t  -- per comment (and SQL standard, but it really is superfluous!)
     GROUP BY Maker
    HAVING COUNT(*) > 1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to find an example that has css rollover using sprites & sliding door
I am trying to find the makers of products who only make laptops and
I'm trying to find one or more concurrent collections to use that I can
So my class has two different UIWebView objects (one is a menu the other
Trying to find some simple SQL Server PIVOT examples. Most of the examples that
Trying to find the sqlserver adapter for rails on windows. I have tried getting
Trying to find an XML file I can use in lieu of a look-up
Trying to find the best way of create an overlap/overlay layer to fill the
Trying to find a good name for a method swapping each coordinate X and
Trying to find a way to send a POST HTTPS request from Python to

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.