Skip to content
Advertisement

How do you populate boolean columns based on a table of properties?

I have a table called Product that contains a product identification number and an id associated with the product identification number.

I also have a property table with the id and property_id

108 refers to the property isNew, 109 refers to the property isPremium and 200 refers to the property isExclusive.

With these, I want to create this temporary table:

How do I do this? You can create a temporary table easily, but I am not sure how to map the values.

Advertisement

Answer

You can do conditional aggregation:

This assumes that there may be several properties per product – unlike what is showed in your sample data. If that’s not the case, aggregation is not necessary:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement