I have 3 tables. A container table. Each container has one or more cargolines stored in a cargoline table. Each cargoline has one or more invoice lines with one or more charge codes stored in an invoiceline table.
container table
containerID, Arrival Date, Vessel, measurement
111 1-5-06 Santa Maria 100.00
cargoline table
cargolineid, containerid, commodity, measurement
222 111 clothes 50.00
333 111 clothes 50.00
invoiceline table
invoicelineid, cargolineid, chargecode amount
333 222 BAM 10.00
334 222 DAF 15.00
335 333 BAM 10.00
336 333 DAF 15.00
The sample container has cargolines that have invoicelines with charge codes = BAM and DAF. I would like to return all containers that do not have a BAM charge on any of it's cargolines. I have tried using a having clause and regular where clauses but it only seems to give me results where if there is one invoiceline that is <> BAM, it will return the container even if another invoiceline does have BAM. I need it to evaluate all invoicelines on all cargolines before deciding to return the container.
Hope I gave enough information! Any help is appreciated.
Thanks
container table
containerID, Arrival Date, Vessel, measurement
111 1-5-06 Santa Maria 100.00
cargoline table
cargolineid, containerid, commodity, measurement
222 111 clothes 50.00
333 111 clothes 50.00
invoiceline table
invoicelineid, cargolineid, chargecode amount
333 222 BAM 10.00
334 222 DAF 15.00
335 333 BAM 10.00
336 333 DAF 15.00
The sample container has cargolines that have invoicelines with charge codes = BAM and DAF. I would like to return all containers that do not have a BAM charge on any of it's cargolines. I have tried using a having clause and regular where clauses but it only seems to give me results where if there is one invoiceline that is <> BAM, it will return the container even if another invoiceline does have BAM. I need it to evaluate all invoicelines on all cargolines before deciding to return the container.
Hope I gave enough information! Any help is appreciated.
Thanks