Project

General

Profile

What is the sql relationship between projects and contacts (companies)

Added by Stefan D over 4 years ago

I have a hard time figuring out the SQL relationship between the companies from the contacts table (where is_company=1) and projects.

The following query works for 95% of the time, but I came to the conclusion that the contacts.first_name is not the relationship to the projects table:

SELECT p.id, p.name FROM custom_values
        INNER JOIN custom_fields c ON c.id = custom_values.custom_field_id 
        INNER JOIN projects p ON p.id = customized_id
        WHERE custom_values.value LIKE '%{CONTACT_FIRST_NAME}%'

Please help.