Topic: sql in code question
this sql query wroks to fill and filter a table grid - now in a form I need to
choose Truck company, Products, Origin and Destination and then get the Flat rate and Surcharge from the database - if there are multiple that match I just need the newest one.
SELECT FreightRateChart.id,
TruckCompanies.Name,
Products.Name,
LoadOrigin.Name,
LoadDestination.Name,
FreightRateChart.FlatRate,
FreightRateChart.Surcharge,
strftime ( '%m/%d/%Y',FreightRateChart.Updated)
From FreightRateChart
LEFT OUTER JOIN TruckCompanies ON FreightRateChart.id_TruckCompanies = TruckCompanies.id
LEFT OUTER JOIN Products ON FreightRateChart.id_Products = Products.id
LEFT OUTER JOIN LoadOrigin ON FreightRateChart.id_LoadOrigin = LoadOrigin.id
LEFT OUTER JOIN LoadDestination ON FreightRateChart.id_LoadDestination = LoadDestination.id
WHERE TruckCompanies.Name LIKE '%{TruckSearch}%'
AND Products.Name LIKE '%{ProdSearch}%'
AND LoadOrigin.Name LIKE '%{OriginSearch}%'
AND LoadDestination.Name LIKE '%{DestSearch}%'
ORDER BY FreightRateChart.id DESC;