开发者

I used "from" and "to" as column titles in my database table, how do I SELECT them?

So I made a table with columns "from" and "to".

While writing to the table is fine because I am inserting one value into each column (and not referencing the columns by name), but whenever I want to retrieve data (SELECT), I want to retrieve... s开发者_开发技巧ay, only the "from" column.

Except as you guessed, it interprets "from" as an SQL command instead of a column name. Surrounding it in quotes just makes "from" populate the result set. Weird.

Can I do anything short of renaming the column? (Which isn't too bad, since the table really has no real data right now).

Thanks!

What I have now: SELECT from,id FROM permissions


Backticks should work in this situation.

e.g.

SELECT `from` FROM myTable;

But ideally you'd rename it. Perhaps to make it more descriptive also, e.g. "rangeFrom" or "dateFrom", etc.


SELECT (`from`,`to`) FROM `permissions`

Update.

Whoops, seems like I'm too slow for this site.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜