Server Side example with query using joins

Server Side example with query using joins

jtaylorjtaylor Posts: 3Questions: 0Answers: 0

I have looked through the server side examples, but am unable to find any using a custom query. All examples I have found seem to use a single table and do not use complex queries involving joins, etc. Has anyone done anything like this? If so, could you point me in the right direction?

Here is an example of one of the queries:

SELECT DISTINCT a.id,parts.id AS part_id, part_name, part_number, part_nsn, part_model, part_cage_code, item_location, item_barcode, item_serial_number, a.item_quantity, item_received_date, item_price, item_added_date, item_gov_barcode, category, manufacturer_name, ownership, system, uoi.code, (SELECT SUM(quantity_issued) FROM issued_items WHERE issued_items.item_id=a.id GROUP BY item_id) AS issued_quantity, (SELECT part_number FROM parts WHERE id = assoc_part_id) AS assoc_part_number
FROM items a
LEFT JOIN parts ON parts.id = a.part_id
LEFT JOIN part_associations ON part_associations.part_id = parts.id
LEFT JOIN categories ON categories.id = a.item_category_id
LEFT JOIN manufacturers ON manufacturers.id = parts.part_manufacturer_id
LEFT JOIN systems ON systems.id = parts.part_system_id
LEFT JOIN uoi ON uoi.id = parts.part_uoi_id
LEFT JOIN ownership ON ownership.id = a.item_ownership_id
WHERE deleted <> 'Y'
ORDER BY part_name

This discussion has been closed.