Say I have a table that has items and attributes listed like,
frog green
cat furry
frog nice
cat 4 legs
frog 4 legs
From the items column I want to select unique objects that have both the green and 4 legs attribute. I would expect to get back just the frog object in this case. What is the most efficient query to do this?
An asterisk (" * ") can be used to specify that the query should return all columns of the queried tables. SELECT is the most complex statement in SQL, with optional keywords and clauses that include: The FROM clause, which indicates the table(s) to retrieve data from.
There are three types of attributes: Free-form attributes, which allow free-form input for text, numbers, dates, or links. Domain-based attributes, which are populated by entities. For more information, see Domain-Based Attributes (Master Data Services).
select item.name
from item
where item.attribute in ('4 legs', 'green')
group by item.name
having count(distinct item.attribute) = 2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With