I have the following tables listed below
Products
- id
- product
- value
- Validity
Queries
- id
- user_id
Product_Consults
- id
- query_id
- product_id
Whenever a user performs a query, the history in the consultas
table and its products are queried in the consultas_produtos
table through the relationship.
How can I construct a SQL
that when listing the products according to query parameters, return only the products that were never queried by the user ?