2012-02-24 69 views
-5

$ sql =「select a.time a.company a.deptime,a.destime,a.flight, a.year,a.month,a.day,」。$ ticket_to_heaven。「as 」。$ this-> condition ['type']。「,」。$ seat。「as 」。$ this-> condition ['type']。「_ s,a.company,a。時間從 ".$this->TBLNAME." a \ n「;mysql查詢替換全選

我想它變成 $ SQL =「選擇.... *」

但我的「a」,錯誤輸出偷偷英寸多麼混亂的'a'!有人可以幫忙嗎? 謝謝

[更新]

我已經改變了它弄成這個樣子:

$ SQL = 「選擇*。」 $ ticket_to_heaven 「爲 」 $此。 - > condition ['type']。「,」。$ seat。「as 」。$ this-> condition ['type']。「_ s,a.company,a.time from ".$this->TBLNAME." a \ n」;

它對我來說仍然有點奇怪。

+0

儘量選擇。*從一個表名不a.anything,a.anythingelse – silly 2012-02-24 08:25:16

+0

這只是一個例子,請重讀我OP也有使用php變量。 – Darcy 2012-02-24 08:30:01

+0

您已經從表中選擇了所有'*',沒有必要使用其他變量,它們只是給您兩次相同的值,並增加了安全風險。 – jeroen 2012-02-24 12:50:21

回答

4

使用

select a.* from table a 

或(沒有別名)

select * from table 
+0

你的意思是把所有的a.time,a.deptime等替換爲。*之後,保持原狀。謝謝 – Darcy 2012-02-24 08:05:06