Evening, im not sure on what im asking here but I will try to explain. I’m not the best at SQL but I do try…
SELECT
qu.job_id, qu.engineer_id, qu.id AS `quote_id`,
jb.author, jb.image_ref, jb.job_title
FROM
`ecom_quotes` qu, `ecom_jobs` jb
WHERE
jb.author = 1
AND
qu.job_id = jb.image_ref
GROUP BY
jb.image_ref
I used the above to list jobs posted by a user and getting other information from other tables based on the job id.
The problem being that if a job has no quotes posted for it, it does not display (qu.job_id = jb.image_ref).
So as a quick fix ( or so I thought ) i replaced it with
( ( qu.job_id = jb.image_ref ) OR ( jb.image_ref != '' ) )
which did work but it returns a quote id when there is no quote associated with it.
Is there anything i can do?
You’ll want to use a
LEFT JOIN.This will still return a record for
ecom_jobseven when there is no matching record inecom_quotes.EDIT: Switched the order of the tables…