我有一個模塊生成一個csv文件,將數據提供給第三方,但希望修改它以供其他公司使用。他們想要的csv的列名與當前模塊中設置的名稱不同,例如Product Name而不是product__name。在MySQL查詢中使用'as'
原國防部的SQL的一個例子是:
$query = 'select
p.products_id as uuid,
t.type_name as product__type,
d.products_name as product__name,
d.products_description as product__description,
d.products_url as product__url,
d.products_viewed as product__viewed_count,
p.products_quantity as product__quantity,
p.products_model as product__model,
p.products_image as product__image
.....
我試圖改變d.products_name爲product__name,以d.products_name作爲產品名稱,但它給了我一個SQL錯誤。
有沒有任何簡單的解決方案,而不必重寫整個模塊?
對於大多數人來說,它是非常狡猾的附上別名,但downvote? – DanFromGermany