Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 内连接与左连接的组合结果_Mysql - Fatal编程技术网

Mysql 内连接与左连接的组合结果

Mysql 内连接与左连接的组合结果,mysql,Mysql,这是我的代码。执行时,我在左连接处遇到错误,表示语法错误。请任何人帮助我…我已经阅读了语法教程,但最后空手而归。谢谢。将WHERE子句移动到查询的末尾。还有,WHERE子句中的trans列是什么?它是从哪里来的?如果它是一个字符串文字,那么将它放在引号中 应该这样写: SELECT name,trans FROM skyplan_deploy.deploy_sids d WHERE apt='KBOS' AND name != trans LEFT JOIN (SELECT distin

这是我的代码。执行时,我在左连接处遇到错误,表示语法错误。请任何人帮助我…我已经阅读了语法教程,但最后空手而归。谢谢。

将WHERE子句移动到查询的末尾。还有,WHERE子句中的trans列是什么?它是从哪里来的?如果它是一个字符串文字,那么将它放在引号中

应该这样写:

SELECT name,trans FROM skyplan_deploy.deploy_sids d WHERE apt='KBOS' AND name != trans  
LEFT JOIN  
(SELECT distinct c.sid_ident as name,c.fix_ident from corept.std_sid_leg as c  
   INNER JOIN  
        (SELECT sid_ident,transition_ident,max(sequence_num) seq,route_type  
         FROM corept.std_sid_leg  
         WHERE data_supplier='J' AND airport_ident='KBOS'  
         GROUP BY sid_ident,transition_ident)b  
         ON c.sequence_num=b.seq and c.sid_ident=b.sid_ident and        c.transition_ident=b.transition_ident  
         WHERE c.data_supplier='J' and c.airport_ident='KBOS')right_tbl  
ON d.name=right_tbl.sid_ident;

这是我的错误。。。您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,查看第2行的“左连接选择不同的c.sid_ident作为名称,c.fix_ident from corept.std_sid_”的正确语法,为什么不使用union?我需要找到数据差异+1以获得敏锐的观察力。如果varchar应该被引用,则为name。我认为这也可能产生错误。@Luv谢谢-我不确定,我只是从问题中复制了它,我认为问题在于名称!=trans',应该引用trans。但是使用它,我没有得到结果集中的差异。左连接通常用于获取左表中的行,而不是右表中的行。不是吗?@user2037445-好的,对不起。请参见“我的编辑”,删除该条件并使用和right_tbl.sid_ident为NULL,以获取左侧而非右侧的行。
SELECT 
  name,
  trans 
FROM skyplan_deploy.deploy_sids d 
LEFT JOIN
(
   SELECT distinct c.sid_ident as name, c.fix_ident 
   from corept.std_sid_leg as c
   INNER JOIN
   (
      SELECT sid_ident, transition_ident, max(sequence_num) seq, route_type
      FROM corept.std_sid_leg
      WHERE data_supplier='J' AND airport_ident='KBOS'
      GROUP BY sid_ident,transition_ident
   ) b ON c.sequence_num=b.seq 
       and c.sid_ident = b.sid_ident 
       and c.transition_ident = b.transition_ident
    WHERE c.data_supplier='J' and c.airport_ident='KBOS'
) AS right_tbl  ON d.name = right_tbl.sid_ident
WHERE apt = 'KBOS'
  AND right_tbl.sid_ident IS NULL ;