我正在尝试根据来自 MySQL 的 tb_images._id 结合四个表的内容返回不同的记录。当我运行我的版本时,我得到了数千条记录。
SELECT DISTINCT
tb_images._id, tb_images._photographer, tb_images._attributed, tb_images._ignore_photographer,
tb_images._origtitle, tb_images._origdate,
tb_images._series,tb_images._show_desc,
tb_images._desc, tb_images._phototype_abbrev,
tb_images._phototype, tb_images._size,tb_images._sitter,
tb_photo_outlets._name, tb_techniques._abbrev,
tb_photographers._fn,tb_photographers._sn
FROM tb_images
LEFT JOIN tb_photo_outlets ON tb_images._source = tb_photo_outlets._id
LEFT JOIN tb_techniques ON tb_images._phototype_abbrev = tb_techniques._abbrev
LEFT JOIN tb_photographers ON tb_images._photographer = tb_photographers._code
WHERE tb_images._id IN (' . $pv_ids . ')
ORDER BY FIELD(tb_images._id,' . $pv_ids . ');';
$pv_ids = 47416,86084,107283,118473,29571,9408,86088
任何建议表示赞赏。
我尝试过不同的 JOINS 和 DISTINCT 的使用,但都没有解决问题。