我有两个表要通过此查询合并为一个表:

SELECT priorities.zadano, priorities.popis, priorities.deadline, priorities.dokonceno, priorities.priorita, priorities.honorar, priorities.zaplaceno, priorities.client_FK, clients.id, clients.jmeno
FROM priorities, clients, firma
WHERE priorities.client_FK=clients.id


但是,正如您在下图中所看到的,它返回的是同一件事的两倍。为什么?

最佳答案

删除firma表,它将正常运行。

SELECT priorities.zadano, priorities.popis, priorities.deadline, priorities.dokonceno, priorities.priorita, priorities.honorar, priorities.zaplaceno, priorities.client_FK, clients.id, clients.jmeno
FROM priorities, clients
WHERE priorities.client_FK=clients.id


您可能在该表中有2条记录,并且在该表上进行自然连接。

关于mysql - 为什么此MySQL查询返回两次?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27771867/

10-11 03:04