mysql php 使用 as 在 rs 中创建额外的列
我有一个问题一直无法找到答案。
我可以通过使用现有列并复制它来在 PHP 记录集中创建一个额外的列:
SELECT
id_tst,
name_tst,
age_tst,
price_tst,
price_tst AS newprice_tst
FROM test_tst
据我所知,AS
只会复制现有列或重命名列 rs。
我想向表中添加两列额外的列,但没有值。
我知道很多人会说这有什么意义?两列没有数据是没有意义的。
原因是我正在为 CMS 系统做一个价格更新模块,用户可以下载包含价格的 .csv
文件,修改电子表格中的价格,然后重新上传 CSV 以更新价格。 额外的两列将用于保存新价格并保留旧价格,以便在必要时可以从 CSV 文件执行回滚。
我可以让客户将两个新列添加到电子表格中,但更希望导出的 CSV 中的列已经就位。
创建 rs 时是否可以创建空白列?
I have a question to which I have been unable to find the answer.
I can create an extra column in a PHP recordset by using an existing column and duplicating it:
SELECT
id_tst,
name_tst,
age_tst,
price_tst,
price_tst AS newprice_tst
FROM test_tst
From what I can work out the AS
will only duplicate an existing colulmn or rename a column rs.
I want to add two extra columns to a table, but with no values.
I know a lot of people will say whats the point in that; it's pointless to have 2 columns with no data.
The reason is I am doing a price updating module for a CMS system, where the user can download a .csv
file containing prices, modify the prices in a spreadsheet then re-upload the CSV to update he prices.
the two extra columns would be to hold the new prices keeping the old so a roll back from the CSV file could be performed if nessecary.
I could just get the client to add the two new colulmns into the spreadsheet, but would prefer to have the exported CSV with the columns already in place.
Is it possible to create blank columns when creaing an rs?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过为空白字符串添加别名来创建空的“虚拟”列:
这将在查询中生成另一列,其中包含所有空白值。
You can create empty "dummy" columns by aliasing a blank string:
This will produce another column in your query with all blank values.