sql查詢資料並匯出問題
阿新 • • 發佈:2020-08-16
使用SQL語句查詢資料後並匯出資料表,結果訂單號顯示 3E+15
原sql:
SELECT
o.order_sn AS '訂單單號',
o.order_amount AS '訂單支付金額',
o.shipping_fee AS '郵費',
o.buyer_id AS '購買人ID',
bm.member_mobile as '購買人手機號',
o.order_state as '訂單狀態',
bm.member_level as '會員等級',
a.true_name AS '收貨人',
a.mob_phone AS '收貨人手機號',
o.store_name AS '店鋪名稱',
DATE_FORMAT( FROM_UNIXTIME( o.add_time ), '%m月%d日%H:%i:%s' ) AS '訂單生成時間',
DATE_FORMAT( FROM_UNIXTIME( o.payment_time ), '%m月%d日%H:%i:%s' ) AS '訂單支付時間',
a.area_info AS '地區',
a.address AS '地址',
c.reciver_info as '客服修改的地址',
m.manufacturer_name AS '廠家',
o.trade_no,
g.goods_name AS '商品規格',
d.goods_spec as '屬性',
g.goods_num AS '商品數量',
g.goods_price AS '商品價格',
g.goods_pay_price AS '商品實際支付價格' ,
c.order_message as '訂單留言',
c.deliver_explain as '發貨備註',
o.gift_type as '禮包等級',
i.consignee_name as '真實姓名',
i.audit_code as '身份證',
d.goods_serial as '商家編碼',
g.gid,
d.goods_jingle as '簡介'
FROM
bbc_order AS o
LEFT JOIN bbc_order_goods AS g ON o.order_id = g.order_id
LEFT JOIN bbc_order_common AS c ON c.order_id = o.order_id
LEFT JOIN bbc_address AS a ON c.address_id = a.address_id
LEFT JOIN bbc_goods AS d ON g.gid = d.gid
LEFT JOIN bbc_manufacturer AS m ON m.id = g.manufacturer_id
LEFT JOIN bbc_member as bm on o.buyer_id = bm.member_id
left join bbc_order_import_consignee i on o.order_id = i.order_id
WHERE
o.order_state in ("20")
and lock_state = 0;
這種情況使用:CONCAT 函式將訂單號輸出為字串格式就可以了
修改後:
SELECT
CONCAT(o.order_sn,'') AS '訂單單號',
o.order_amount AS '訂單支付金額',
..........