更新-
没关系,我用php端修复它,并使用“ distinct”,最终查询(解决方案)是这样的:
从denunciaMedicamentos AS中选择不同的m.idDenuncia AS m在p.id = m.idDenuncia AS中加入denuncias AS
SELECT * FROM denunciaMedicamentos AS m
JOIN denuncias AS p
WHERE p.id=m.idDenuncia
ORDER BY m.medicamento
它有效,但是它重复列
id
和idDenuncia
。结果是:idDenuncia
是对denuncias表的引用。我想知道,该怎么办,它不会重复数据(
id
)? 最佳答案
从一个表中全选,然后从另一个表中选择将解决您的问题
SELECT m.*,p.col1,p.col2 FROM denunciaMedicamentos AS m JOIN denuncias AS p WHERE p.id=m.idDenuncia ORDER BY m.medicamento