4
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;

これは私のコードです..実行すると、左結合で構文が間違っているというエラーが表示されます.誰か助けてください...構文チュートリアルを実行しましたが、手ぶらで終わります.ありがとう.

4

1 に答える 1

4

WHERE句をクエリの最後に移動します。また、節のその列は何transですか? WHEREそれはどこから来たのか?文字列リテラルの場合は、引用符で囲みます。

次のように記述します。

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 ;
于 2013-03-21T07:16:11.613 に答える