imstillatwork
IS-IT--Management
Tables:
members
-----------------------------------
id (unique) | member_type (o or c)
-----------------------------------
project_types
------------
id (unique)
------------
member2type
-----------------------------
member_id | projecy_type_id
-----------------------------
project
------------------------
id (unique) | county_id
------------------------
project2type
-------------------------------
project_id | projecy_type_id
-------------------------------
contractor2county
------------------------
member_id | county_id
------------------------
Query so far
This query will return results, but I need it onyl return rows where the contractor2type.project_type_id matches ALL of the project2type.project_type_ids
So a contractor selects multiple job types (concrete, flooring, etc...) that they are willing to work on. And a project owner selectes multiple project types that are required for the job.
right now it returns rows where any one of the contractors project_types matches any one of the projects project_types
So if a job requires 3 project_types, and a contractor has one of them, it matches, but the contractor should have to have all of them before that row is returned....
??? I thought it could be done in s sigle query, if not, I will find a long way to do it....
THANKS!
Kevin
Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!
members
-----------------------------------
id (unique) | member_type (o or c)
-----------------------------------
project_types
------------
id (unique)
------------
member2type
-----------------------------
member_id | projecy_type_id
-----------------------------
project
------------------------
id (unique) | county_id
------------------------
project2type
-------------------------------
project_id | projecy_type_id
-------------------------------
contractor2county
------------------------
member_id | county_id
------------------------
Query so far
Code:
SELECT
p.id AS project_id
,p.county_id AS project_county
,p.project_type_id AS project_type
,c2type.member_id AS contractor_id
,c2type.project_type_id AS contractor_project_type
,c2c.county_id AS contractor_county
FROM project AS p
LEFT JOIN project2type AS p2t ON p2t.project_id = p.id
LEFT JOIN member2type AS c2type ON c2type.project_type_id = p.project_type_id
LEFT JOIN members AS c ON c.id = c2type.member_id AND c.member_type = 'c'
LEFT JOIN contractor2county AS c2c ON c2c.member_id = c2type.member_id
WHERE c2c.county_id = p.county_id
This query will return results, but I need it onyl return rows where the contractor2type.project_type_id matches ALL of the project2type.project_type_ids
So a contractor selects multiple job types (concrete, flooring, etc...) that they are willing to work on. And a project owner selectes multiple project types that are required for the job.
right now it returns rows where any one of the contractors project_types matches any one of the projects project_types
So if a job requires 3 project_types, and a contractor has one of them, it matches, but the contractor should have to have all of them before that row is returned....
??? I thought it could be done in s sigle query, if not, I will find a long way to do it....
THANKS!
Kevin
Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!