Search code examples
mysqlsqlrelational-division

Using SQL IN AND together


Is there a way to use IN and AND together? The problem is that I want to match my query to multiple values using one column.

SELECT * FROM product INNER JOIN values USING(product_id) WHERE value = "large" AND value = "short"

The problem is I can't use the IN clause, because it defines as OR between the values.


Solution

  • Try:

    select product_id
    from values
    where value in ('large','short')
    group by product_id
    having count(distinct value) = 2