执行完全外部联接时出错

Error doing a Full Outer Join

product table:

╔══════════════════════════════════╦═══════════╦═══════════════════╦════════════════════╦════╗
║               ref                ║    mfr    ║       pnum        ║        ssku        ║ id ║
╠══════════════════════════════════╬═══════════╬═══════════════════╬════════════════════╬════╣
║ 6541_aten_2a-130g                ║ Aten      ║ 2A-130G           ║ 2A-130G            ║  6 ║
║ 7466_eaton_5sc1000i              ║ Eaton     ║ 5SC1000I          ║                    ║  8 ║
║ 8214_ivanti-uk_template-material ║ IVANTI UK ║ TEMPLATE MATERIAL ║ 000000000003616655 ║  4 ║
║ 8361_aywun_92sfan1               ║ Aywun     ║ 92SFAN1           ║ 92SFAN             ║  9 ║
║ 9824_autodesk_00100-000000-9880  ║ AUTODESK  ║ 00100-000000-9880 ║ 00100-000000-9880  ║  5 ║
╚══════════════════════════════════╩═══════════╩═══════════════════╩════════════════════╩════╝

inventory table:

╔══════════════════════════════════╦═══════╦═════════╦═════════════════════╗
║               ref                ║ scost ║ instock ║        date         ║
╠══════════════════════════════════╬═══════╬═════════╬═════════════════════╣
║ 6541_aten_2a-130g                ║    26 ║       0 ║ 2017-05-27 10:45:23 ║
║ 7466_eaton_5sc1000i              ║   489 ║       0 ║ 2017-05-27 10:45:23 ║
║ 8214_ivanti-uk_template-material ║     0 ║       0 ║ 2017-05-27 10:45:23 ║
║ 8361_aywun_92sfan1               ║     4 ║       0 ║ 2017-05-27 10:45:23 ║
║ 9824_autodesk_00100-000000-9880  ║   738 ║       0 ║ 2017-05-27 10:45:23 ║
╚══════════════════════════════════╩═══════╩═════════╩═════════════════════╝

...我正在寻找一个 FULL OUTER JOIN(如果我理解正确的话,只有当键存在于两个 table 时才从两个 table 中获取列?)使用 Medoo :

$data = $database->select("product", [
    "[<>]inventory" => ["ref" => "ref"],
]);

错误:

Invalid argument supplied for foreach() in /var/www/html/vendor/catfan/medoo/src/Medoo.php on line

我也在控制台中尝试了这些查询,但出现语法错误:

SELECT *
FROM product
FULL OUTER JOIN product ON product.ref = inventory.ref;

SELECT * FROM `product`, * FROM `inventory` 
WHERE product.`ref` = inventory.`ref`;

预期结果:

╔═══════════════════╦══════╦═════════╦═════════╦════╦═══════╦═════════╦═════════════════════╗
║        ref        ║ mfr  ║  pnum   ║  ssku   ║ id ║ scost ║ instock ║        date         ║
╠═══════════════════╬══════╬═════════╬═════════╬════╬═══════╬═════════╬═════════════════════╣
║ 6541_aten_2a-130g ║ Aten ║ 2A-130G ║ 2A-130G ║  6 ║    26 ║       0 ║ 2017-05-27 10:45:23 ║
╚═══════════════════╩══════╩═════════╩═════════╩════╩═══════╩═════════╩═════════════════════╝

Mysql不支持FULL OUTER JOIN,你的逻辑好像是INNER JOIN:

SELECT *
FROM product
INNER JOIN inventory ON product.`ref` = inventory.`ref`;

但是我不知道为什么两个表中的ref都是一样的,你期望的结果只有一条记录,根据Medoo的文档,代码应该是这样的:

$data = $database->select(
   "product",
    [
       "[><]inventory" => "ref"
    ],
    "*");

对于你所有的表,试试这个:

$data = $database->select(
   "product",
    [
       "[><]inventory" => "ref",
       "[><]detail" => "ref",
       "[><]moredetails" => "ref",
       "[><]info" => "ref",
       "[><]images" => "ref",
       "[><]features" => "ref",
       "[><]categories" => "ref",
       "[><]tags" => "ref"
    ],
    ["product.*", "inventory.*"]);