DreamAwake
Registered User.
- Local time
- Today, 01:02
- Joined
- Dec 13, 2007
- Messages
- 23
I have attached a screen shot of my database schema.
This is my scenario;
There are 3 different situations when it comes to searching a quote.
1. You have a job with 0 quotes.
2. You have a job with say 3 quotes, but none have been awarded.
3. You have a job with 3 Quotes, 1 or 2 have been awarded.
I want to have a query which lists all quotes but if the job has awarded 1 of the quotes I don't want to see the others. But I still need to see new jobs without quotes. I understand outer joins are needed but honestly i've spent hours on this and need some major assistance.
I have the following so far which is showing all quotes but is displaying un-awarded quotes when a quote has been awarded.
This is my scenario;
There are 3 different situations when it comes to searching a quote.
1. You have a job with 0 quotes.
2. You have a job with say 3 quotes, but none have been awarded.
3. You have a job with 3 Quotes, 1 or 2 have been awarded.
I want to have a query which lists all quotes but if the job has awarded 1 of the quotes I don't want to see the others. But I still need to see new jobs without quotes. I understand outer joins are needed but honestly i've spent hours on this and need some major assistance.
I have the following so far which is showing all quotes but is displaying un-awarded quotes when a quote has been awarded.
Code:
SELECT tblContract.MNW, tblContract.Location, tblContract.Status, tblCompany.CompanyName, tblQuote.awarded
FROM (tblContract LEFT JOIN tblQuote ON tblContract.ContractID = tblQuote.ContractID) LEFT JOIN tblCompany ON tblQuote.CompanyID = tblCompany.CompanyID
GROUP BY tblContract.MNW, tblContract.Location, tblContract.Status, tblCompany.CompanyName, tblQuote.awarded
HAVING (((tblContract.MNW)="mw000669") AND ((tblQuote.awarded)=1));