Hi
I'm having trouble trying to join the information of three tables together in an single SQL statement. It can be done in two statements but its a bit wasteful!
I'm trying to get information from the Contract and ClientRT tables which fulfil certain specifications(Contract.FromDate must be between two dates and ClientRT.ReportsTo must be within a set of values). When I find this data I want to get PartMaster.DescText for the selected record.
This is my code:
And this is the resulting statement, which will not sucessfully open a recordset:
The error thrown-up tells me there is incorrect syntax near '.'!! Its got to be something to do with the join statements as it works if I don't try to get information from the PartMaster table. I've tried various different types of join and they don't seem to work.
Any help much appreciated!!!
I'm having trouble trying to join the information of three tables together in an single SQL statement. It can be done in two statements but its a bit wasteful!
I'm trying to get information from the Contract and ClientRT tables which fulfil certain specifications(Contract.FromDate must be between two dates and ClientRT.ReportsTo must be within a set of values). When I find this data I want to get PartMaster.DescText for the selected record.
This is my code:
Code:
var select = "SELECT Contract.ContractNo, Contract.CustomerID, Contract.FromDate, ClientRT.FirstName, ClientRT.LastName, ClientRT.PhoneBusiness PartMaster.DescText AS ToolDesc ";
select = select + "FROM (ClientRT RIGHT JOIN Contract ON ClientRT.AccNumber=Contract.CustomerID) LEFT JOIN PartMaster ON Contract.PartNumber=PartMaster.PartNumber ";
select = select + "WHERE ClientRT.ReportsTo IN("+rsCustomers('AccNumber');
rsCustomers.MoveNext();
while(!rsCustomers.EOF){
select = select + "," + rsCustomers('AccNumber');
rsCustomers.MoveNext();
}
select = select + ") AND Contract.FromDate >= '"+getUSDateString(today)+"' AND Contract.FromDate < '"+getUSDateString(until)+"'";
And this is the resulting statement, which will not sucessfully open a recordset:
Code:
SELECT Contract.ContractNo, Contract.CustomerID, Contract.FromDate, ClientRT.FirstName, ClientRT.LastName,ClientRT.PhoneBusiness PartMaster.DescText AS ToolDesc FROM (ClientRT RIGHT JOIN Contract ON ClientRT.AccNumber=Contract.CustomerID) LEFT JOIN PartMaster ON Contract.PartNumber=PartMaster.PartNumber WHERE ClientRT.ReportsTo IN(59,61) AND Contract.FromDate>='9/15/2004' AND Contract.FromDate<'9/22/2004'
Any help much appreciated!!!