I've got table with properties of some products:
table properties(
prop_id int,
product_id int
)
My question is: is it possible to select properties that match without filtering them from the result? For example:
select property_id from properties WHERE property_id IN(1,3,5);
You get only rows that match 1,3,5. I need all rows but with information of which rows matched my criteria. I don't want to use 'UNION'.
Thanks for help.
I don't have experience with mySQL, but assuming it supports a case statement (or something analagous), you could do this:
select
prop_id,
product_id,
(case when prop_id in (1, 3, 5) then 1 else 0 end) as matches_criteria
from properties
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