PRODUCTSテーブルのデータを調べます。

これらのクエリを調べます。
1.製品名、製品リストを選択します
FROM製品
WHERE prod 1ist NOT IN(10,20) AND category _id=1;
2. SELECT prod name, | prod _ list
FROM products
WHERE prod list < > ANY (10,20) AND category _id= 1;
SELECT prod name, prod _ list
FROM products
WHERE prod_ list <> ALL (10, 20) AND category _ id= 1;
どのクエリが同じ出力を生成しますか?
正解:A
Based on the given PRODUCTS table and the SQL queries provided:
Query 1: Excludes rows where prod_list is 10 or 20 and category_id is 1.
Query 2: Includes rows where prod_list is neither 10 nor 20 and category_id is 1.
Query 3: Excludes rows where prod_list is both 10 and 20 (which is not possible for a single value) and category_id is 1.
The correct answer is A, queries 1 and 3 will produce the same result. Both queries exclude rows where prod_list is 10 or 20 and include only rows from category_id 1. The NOT IN operator excludes the values within the list, and <> ALL operator ensures that prod_list is not equal to any of the values in the list, which effectively excludes the same set of rows.
Query 2, using the <> ANY operator, is incorrect because this operator will return true if prod_list is different from any of the values in the list, which is not the logic represented by the other two queries.