2012-02-24 72 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