SELECT receipts_body.receipt_id,items.id,items.title FROM receipts_body
LEFT JOIN items ON items.id = receipts_body.item_id
ORDER BY receipt_id
获取主要类别的收据
SELECT receipts_body.receipt_id,items.id,items.title FROM receipts
LEFT JOIN items ON items.id = receipts_body.item_id
WHERE receipt_id IN (SELECT receipt_id FROM receipt_body WHERE item_id = 771013)
ORDER BY receipt_id
获取小类收据
SELECT receipts_body.receipt_id,items.id,items.title FROM receipts
LEFT JOIN items ON items.id = receipts_body.item_id
WHERE receipt_id IN (SELECT receipt_id FROM receipt_body WHERE item_id = 771012)
ORDER BY receipt_id
1条答案
按热度按时间r1zhe5dt1#
去拿收据上的东西
获取主要类别的收据
获取小类收据