简体   繁体   中英

How are these two queries different?

I am working on my assignment which uses this schema (simplified) :

parts(pid,color)
catalog(seller_name,pid)

I have to write two queries :

> Find the seller that sell every red part or every green part?

So, from my understanding, I have to find sellers that sell every red part, then sellers that sell every green part and do the union.

Another query is :

> Find the seller that sell every red or green part?

How is this query different from the query above?

Find the seller that sell every red part or every green part?

I think you've interpreted this correctly.

Find the seller that sell every red or green part?

This would be only the sellers that sell every red parts, as well as every green part. It's not the same as the union of the first two groups. It seems more like the intersection.

Frankly, I think it's worded poorly and if you were getting paid, you would need to clarify the statement with your vendor.

I would think about it like this-

Find the seller that sell (every red part) or (every green part)?

vs

Find the seller that sell every (red or green) part?

So the first would be only looking for sellers that sell each respective color (although if you wanted to analyze this even further, the question does say EVERY, so you may even need to restrict your selection to only sells that have sold EVERY part of their respective colors).

Whereas the latter would be the sellers that sell red + green parts (note that the word EVERY was used here too).

Although there is definitely room for misinterpretation here, and like others have said I would try to get some more clarification if possible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM