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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:08:07+00:00 2026-06-12T17:08:07+00:00

What different? RIGHT: select distinct maker, price from product inner join printer on product.model

  • 0

What different?

RIGHT:

select distinct maker, price from product
inner join printer
on product.model = printer.model
where color = 'y' and price <= (select min(price) from printer where color = 'y')

WRONG:

select distinct maker, price from product
inner join printer
on product.model = printer.model
where color = 'y' and price <= all (select distinct price from printer where color = 'y')

I know using “min” is better in performance.
But could anyone explain what wrong and different in the result?

Tables structures:

Product(maker, model, type)
Printer(code, model, color, type, price)

neikel

  • 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-12T17:08:09+00:00Added an answer on June 12, 2026 at 5:08 pm

    ALL is a short form for expanding the comparison operator against ALL rows, and combining the conditions with AND.
    ANY is a short form for expanding the comparison operator against ALL rows, and combining the conditions with OR.

    Specifically,

    price <= all (select distinct price from printer where color = 'y')
    

    expands to, assuming the subquery returns 4 rows

    price <= <price1> AND
    price <= <price2> AND
    price <= <price3> AND
    price <= <price4>
    

    When any of those resove to NULL, the result is false because NULL is not comparable using <=. MIN doesn’t have this problem (because MIN skips NULLs) except for the edge case where there is NO result row, in which case <= (select MIN..) can also give you an unexpected result.

    Using ALL in to perform a test against a nullable column should almost always be qualified with a filter, e.g.

    select distinct maker, price from product
    inner join printer
    on product.model = printer.model
    where color = 'y' and price <=
          all (select distinct price from printer where color = 'y'
               where price is not null)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to do the following: The client (from a different domain, right now
I'm looking for a query to select rows from two different tables, keeping the
I have this query: SELECT DISTINCT u.id, u.name, n.network_id, n.perm FROM users as u
This is my query right now: SELECT a.stacct, b.hacct, a.stfrqcode, b.thfrqcode FROM st a
Right now I have three different select box sections, they are all states or
So what I'm trying to do is select all the distinct months from my
i need to select distinct value from a multiple union. I nee to use
How do I make the left and right gutters different colors with 960.gs? When
I'm making a right toolbar with different buttons on it. When i rollover it,
I am trying to print out documents in various different orders. Right now 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.