作者razor (=_=)
看板Database
标题Re: [SQL ] MySQL之巢状Select,Delete
时间Thu Jun 22 22:03:46 2006
※ 引述《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