Hi,
Normally use mysql but am having to use a 3rd parties DB with an ODBC driver that doesnt support JOINS and am having trouble getting a query to work.
sql looks like - which works fine and returns one record
but if i want to query two [or more] vehicles i thought i would change the sql to
but this returns loads of records - can anyone see what the prob is?
if i query each id separately they return one record each.
Normally use mysql but am having to use a 3rd parties DB with an ODBC driver that doesnt support JOINS and am having trouble getting a query to work.
sql looks like - which works fine and returns one record
Code:
SELECT MK_01_CustomerRecords.FirstName, MK_01_CustomerRecords.Surname,
MK_01_CustomerRecords.Address001, MK_01_CustomerRecords.Postcode,
MK_01_vehicleRecords.registrationnumber
FROM MK_01_VehicleRecords, MK_01_customerrecords, MK_01_vehiclelinkindex
WHERE MK_01_vehicleRecords.vehicleNumber = MK_01_vehiclelinkindex.vehiclemagicno
AND MK_01_CustomerRecords.CustomerNumber = MK_01_vehiclelinkindex.ctmagicnumber
AND MK_01_vehiclelinkindex.vehiclestatus ='C'
AND MK_01_VehicleRecords.vehiclenumber = '136225'
but if i want to query two [or more] vehicles i thought i would change the sql to
Code:
SELECT MK_01_CustomerRecords.FirstName, MK_01_CustomerRecords.Surname,
MK_01_CustomerRecords.Address001, MK_01_CustomerRecords.Postcode,
MK_01_vehicleRecords.registrationnumber
FROM MK_01_VehicleRecords, MK_01_customerrecords, MK_01_vehiclelinkindex
WHERE MK_01_vehicleRecords.vehicleNumber = MK_01_vehiclelinkindex.vehiclemagicno
AND MK_01_CustomerRecords.CustomerNumber = MK_01_vehiclelinkindex.ctmagicnumber
AND MK_01_vehiclelinkindex.vehiclestatus ='C'
AND MK_01_VehicleRecords.vehiclenumber = '136225'
OR MK_01_VehicleRecords.vehiclenumber = '196451'
but this returns loads of records - can anyone see what the prob is?
if i query each id separately they return one record each.