I have 3 tables:
Jobs | messages | Quotes
the jobs
table has all information about a posted job. The job_id
is auto_increment
.
The message
s table contains a message if one is posted against the jobs job_id
.
Quotes
table contains any quotes submitted against the jobs job_id
.
I want to:
select all from jobs where ...blah
select if exists from messages any message where messages table job_id = job table job_id
select if exists from quotes any quote where quotes job_id = job table job_id
is this possible? i did this left join query, but it gives duplicate results.
$sql = "SELECT DISTINCT jobs.job_id AS jobid,
jobs.worktitle AS wrktitle,
jobs.workinfo AS wrkinfo,
messages.message AS msg FROM jobs
LEFT JOIN messages ON
jobs.job_id = messages.job_id
LEFT JOIN quotes ON
jobs.job_id = quotes.workid";
Please Help! Thanks steve
ok sorry my question wasnt great. iam trying to query my jobs table which is straight forward. However i have 2 other tables associated with this table via a job id column. messages and quotes. The message table contains any questions asked about a particular job via the job id -- The quotes table contains any quotes submitted against a particular job via job id. I have tried to query the jobs table and join the messages and quote tables via job id. but this gives duplicate rows of the jobs table. is it possible to query the jobs table, and show any messages or quotes? – Stevie P