Difficulty understanding simple subqueries

After noon,

I was asked to return some specific recordsets using subqueries, however, I find it difficult to understand how to use subqueries to get specific results.

Ex Using a subquery, list the product name from the product table for orderNumber 10121 from the orderdetails table.

I tried:

SELECT productName 
FROM products 
WHERE (SELECT orderNumber FROM orderdetails WHERE orderNumber = 10121); 

but apparently I missed something.

Any help would be appreciated.

+4
source share
1 answer

. , , . , , , . , SQL :

SELECT productName FROM products WHERE productNumber IN (SELECT productNumber FROM orderdetails WHERE orderNumber = 10121);

, !

+2

Source: https://habr.com/ru/post/1658948/


All Articles