나는 두 개의 테이블 raw_materials
과 raw_materials_moves
을 가지고 있습니다.각 항목의 마지막 3 행 선택
raw_materials
는 필드
id, name
raw_materials_moves
갖는다
id, raw_material_id, price, created
은 그래서, 각 원료의 select
마지막 3 개 이동하기 위해 필요한이 필드
난이 쿼리하지만 나던가 있습니다 직장
SELECT a.*, b.price, b.created
FROM raw_materials a
LEFT JOIN
(SELECT price, raw_material_id, created FROM raw_material_moves ORDER BY created DESC LIMIT 3) b
ON b.raw_material_id=a.id
ORDER BY a.id
저는 정말 MySQL에 대한 새로운 내용입니다. 제발 좀 도와주세요. – borfrank