Khi bạn lọc trên THAM GIA NGOÀI RA, bạn phải lọc trong mệnh đề BẬT hoặc dưới dạng bảng dẫn xuất. Khi image.display_order = '1'
ở WHERE, nó sẽ luôn là THAM GIA BÊN TRONG
SELECT
topic.content_id,
topic.title,
image.location
FROM
mps_contents AS topic
LEFT JOIN
mps_contents AS image ON topic.content_id = image.page_id
AND image.display_order = '1'
WHERE
topic.page_id = (SELECT page_id FROM mps_pages WHERE page_short_name = 'foo' )
hoặc
SELECT
topic.content_id,
topic.title,
image.location
FROM
mps_contents AS topic
LEFT JOIN
(
SELECT *
FROM mps_contents
WHERE display_order = '1'
) AS image ON topic.content_id = image.page_id
WHERE
topic.page_id = (SELECT page_id FROM mps_pages WHERE page_short_name = 'foo' )