新手求解Unknown column 'tb_sell_tbfinance.ticket_no' in 'field list' 的问题(已经解决)

Dyson1990 发布于 2016/05/25 16:13
阅读 273
收藏 0
mysql> SELECT
    -> REPLACE(tb_sell_tbfinance.`ticket_no`,'-','') AS ticket_no,
    -> tb_sell_tbfinance.offer_time,
    -> tb_sell_tbfinance.passenger_name,
    -> tb_sell_tbfinance.range_type,
    -> tb_sell_tbfinance.`range`,
    -> tb_sell_tbfinance.flt_date,
    -> tb_sell_tbfinance.airline,
    -> tb_sell_tbfinance.flt_no,
    -> tb_sell_tbfinance.bin_type,
    -> tb_sell_tbfinance.passenger_type,
    -> tb_sell_tbfinance.ticket_price,
    -> tb_sell_tbfinance.discount,
    -> tb_sell_tbfinance.concessionary_fare,
    -> tb_sell_tbfinance.sharing_fare,
    -> tb_sell_tbfinance.airrax,
    -> tb_sell_tbfinance.oilrax,
    -> tb_sell_tbfinance.total_fare,
    -> tb_sell_tbfinance.agency_fee_ratio,
    -> tb_sell_tbfinance.brokerage,
    -> tb_sell_tbfinance.pnr,
    -> tb_sell_tbfinance.order_type,
    -> tb_sell_tbfinance.order_no,
    -> tb_sell_tbfinance.corresponding_order_no,
    -> tb_sell_tbfinance.zfb_serial_no
    -> FROM
    -> tb_sell_tbfinance as A
    -> LEFT JOIN
    -> (
    -> SELECT
    -> REPLACE(tb_pay_zfb_income.merchant_order_no,'et-p-','') AS merchant_order
_no,
    -> tb_pay_zfb_income.posting_amount
    -> FROM
    -> tb_pay_zfb_income
    -> WHERE
    -> tb_pay_zfb_income.business_type = '交易付款' AND
    -> tb_pay_zfb_income.merchant_order_no NOT LIKE 'et-p-m-%'
    -> ) as B
    -> ON A.order_no = B.merchant_order_no ;
ERROR 1054 (42S22): Unknown column 'tb_sell_tbfinance.ticket_no' in 'field list'





如图,ticket_no这一列是肯定存在的,试了好久都是这个结果,单独运行A表的那个查询也是成功的

感谢各位大神指点迷津



加载中
0
温安适
温安适

你给tb_sell_tbfinance 起了别名A,所有select后的tb_sell_tbfinance需要修改为A,修改后的SQL为:

SELECT
     REPLACE(A.`ticket_no`,'-','') AS ticket_no,
     A.offer_time,
     A.passenger_name,
     A.range_type,
     A.`range`,
     A.flt_date,
     A.airline,
     A.flt_no,
     A.bin_type,
     A.passenger_type,
     A.ticket_price,
     A.discount,
     A.concessionary_fare,
     A.sharing_fare,
     A.airrax,
     A.oilrax,
     A.total_fare,
     A.agency_fee_ratio,
     A.brokerage,
     A.pnr,
     A.order_type,
     A.order_no,
     A.corresponding_order_no,
     A.zfb_serial_no
     FROM
     tb_sell_tbfinance as A
     LEFT JOIN
     (
     SELECT
     REPLACE(tb_pay_zfb_income.merchant_order_no,'et-p-','') AS merchant_order
_no,
     tb_pay_zfb_income.posting_amount
     FROM
     tb_pay_zfb_income
     WHERE
     tb_pay_zfb_income.business_type = '交易付款' AND
     tb_pay_zfb_income.merchant_order_no NOT LIKE 'et-p-m-%'
     ) as B
     ON A.order_no = B.merchant_order_no ;




温安适
温安适
回复 @Dyson1990 : 客气啦
D
Dyson1990
所有问题迎刃而解,好人一生平安
返回顶部
顶部