看板 Database 關於我們 聯絡資訊
※ 引述《qrtt1 (愚人)》之銘言: : delete from products where category = EXISTS ( select id from categories : where parent=42); : delete from products where category = ANY ( select id from categories : where parent=42); : 不知那是對的, 沒有data可以測..xd EXISTS那一句是錯的,因為EXISTS是判斷一個集合是否存在,傳回真偽值. "where category = EXISTS (..." 這樣的子句只判斷category是真或偽, 不是所要的作法. 第二句...可能是對的, 除非子查詢 "(select id from )" 取回包含多於一項元素的集合... 如果子查詢取回一個集合X,想想看,"where category = ANY X"是什麼意思? 恆false! 因為category最多只會等於X其中一項元素. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.160.214.21