Code:
Select sohd from HOADON where not exists ( select * from SANPHAM where nuocsx=‘Trung Quoc’ and not exists ( select * from CTHD where HOADON.sohd=CTHD.sohd and CTHD.masp=SANPHAM.masp) )
Code:
select * from SANPHAM where nuocsx=‘Trung Quoc’ and not exists ( select * from CTHD where HOADON.sohd=CTHD.sohd and CTHD.masp=SANPHAM.masp) )
NOT EXISTS trả về giá trị True khi không có bộ giá trị nào trả về.
Đưa câu truy vấn "Những sản phẩm mà SoHD đó chưa mua" trở thành điều kiện NOT EXISTS nữa thì sẽ được câu truy vấn phép chia hoàn chỉnh mà bạn đã có. Chắc chắn bạn sẽ tự suy ra được kết quả là: Số HD đã mua tất cả sản phẩm do Trung Quốc sản xuất.
Leave a comment: