I need to know which table acts as an intermediary to achieve the many-to-many relationship between these entities.
I know that the table that stores the products is vtiger_products
and that the one that keeps the quotes is vtiger_quotes
but I do not know which table relates both, so my query is incomplete.
So...
SELECT * FROM vtiger_quotes
INNER JOIN vtiger_products INNER JOIN table_relates_both
ON vtiger_quotes.quoteid = table_relates_both.quoteid
AND vtiger_products.productid = table_relates_both.productid
WHERE vtiger_quotes.potentialid = ?
What's the real name of table_relates_both
?
vtiger_inventoryproductrel
is the intermediary table between vtiger_quotes
and vtiger_products
Below is the structure of vtiger_inventoryproductrel
where id
column act as a foreign key of Quotes
, Opportunity
, Invoice
etc
If you want to fetch Quotes related to particular Opportunity then you need to execute below query:
SELECT {your required field goes here} FROM vtiger_inventoryproductrel INNER JOIN vtiger_quotes
ON vtiger_quotes.quoteid = vtiger_inventoryproductrel.id
WHERE vtiger_quotes.potentialid = $potential_id
Also note that:
vtiger_crmentity - This is core table in which an entry is added for all entity type records. This stores meta information like record id, record owner id, last modified by user id, created time, modified time and description.