Jump to content

SQL ANY, ALL mistake by W3Schools


amitj
 Share

Recommended Posts

Question:

The following SQL statement returns TRUE and lists the product names if it finds ANY records in the OrderDetails table that quantity = 10

Answer by W3Schools.com

SELECT ProductName
FROM Products
WHERE ProductID = ANY (SELECT ProductID FROM OrderDetails WHERE Quantity = 10);

which is wrong, as the result showing by above query is 31, but right answer will be 44

select productname, quantity
from products
inner join orderdetails on products.productid=orderdetails.productid and quantity=10
order by productname

please verify and confirm.

 

Link to comment
Share on other sites

  • 3 weeks later...
select Products.productId,Product.ProductName,Orderdetails.quantity 

from Products 

inner join Orderdetails 

on Products.productId=Orderdetails.productId 

where Orderdetails.quantity=10 

Order By Products.ProductName

I think this was is help for you

Link to comment
Share on other sites

  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...