I have 3 tables in a database. Product with product_id, Functionality with functionality_id and product_funcionality (product_funcionality_id, product_id, functionality_id)
I need a query to find products where you can select all products that contain the 'minimum' such functionality.
If the Product P1 has the F1, F5, F10 features
The query should find products that contain exactly the same features, F1, F5, F10, but it should show the products that have some added functionality.
You can display products with:
P1 -> F1, F2, F3, F5, F10,
P2 -> F1, F5, F6, F10,
P3 -> F1, F3, F5, F10, F11,
Can not display:
P4 -> F1, F2, F10,
P5 -> F1, F5, F11
I'm struggling to write a query to ensure that business rule, can not write 'find the products with at least such features'.
The IN clause does not address directly.
I do like to write SQL to get the products with at least such features? appreciate
EDIT:
I had to add the functionality_type table, and the queries are made from the type of functionality, only you must follow the same structure described above, the table functionality_type that will be used to refer to all products that have a certain type of functionality. Changing the Having Clause to grab at least all products containing features with type_funtionality_id?
Each type of functionality is just a key with the name. Also funcionality is related with brands.