1
私は左の結合で2つのテーブルを結合しようとしていますが、何かがそれとは関係ありません。MYSQLdbを使ってPython 2.7で正しく左結合を作成するには?
私は、このエラーコードを取得する:"You have an error in your SQL syntax to use near 'EXAMINED_AIRPORT_AIRPORT
'\n
EXAMINED_AIRPORT_COUNTRY
、\n
ARRIV`' 23" 行で、ここで
私のコード:
connection = MySQLdb.connect(host='localhost',
user='adam',
passwd='',
db='database1',
use_unicode=True,
charset="utf8")
cursor = connection.cursor()
query = """ select
`ACTUAL_TIME`,
`ACTUAL_DAY`,
`EXAMINED_AIRPORT_CODE`,
`EXAMINED_AIRPORT_AIRPORT`,
`EXAMINED_AIRPORT_COUNTRY`,
`ARRIVALS/DEPARTURES`,
`SCHEDULED_TIME`,
`FLIGHT`,
`FROM`,
`AIRLANE`,
`AIRCRAFT`,
`STATUS`,
`FLIGHT_ID_1`,
`FLIGHT_ID_2`,
`UPLOAD_TIME`
from OSSZES as a
left join (
select
`ACTUAL_TIME`
`ACTUAL_DAY`,
COALESCE(`EXAMINED_AIRPORT_CODE`, '') as EXAMINED_AIRPORT_CODE
`EXAMINED_AIRPORT_AIRPORT`,
`EXAMINED_AIRPORT_COUNTRY`,
`ARRIVALS/DEPARTURES`,
`SCHEDULED_TIME`,
`FLIGHT`,
`FROM`,
`AIRLANE`,
`AIRCRAFT`,
`STATUS`,
`FLIGHT_ID_1`,
`FLIGHT_ID_2`,
`UPLOAD_TIME`
from OSSZES_CLEAR
) as b using (`ACTUAL_DAY`,`EXAMINED_AIRPORT_CODE`,`FLIGHT`,`SCHEDULED_TIME`,`STATUS`)
where b.EXAMINED_AIRPORT_CODE is null
into outfile '/tmp/proba.csv'
fields terminated by ';'
enclosed by '"'
lines terminated by '\n';
"""
cursor.execute(query)
connection.commit()
cursor.close()
? – Harley
'a' .' ACTUAL_TIME' –
そしてどこで使用する必要がありますか?どう思いますか? – Harley