显示数据库中的列(Display of Columns From Database)

编程入门 行业动态 更新时间:2024-10-17 13:31:21
显示数据库中的列(Display of Columns From Database)

我有3个文本文件,每个文件包含20个项目的列表。 每个新的一天都会添加一个新列。

我想以电子表格或电子表格类型的布局显示这些项目,每列与下一列相邻。

电子表格输出如下所示:

10-28-09 10-29-09 10-30-09 data1 data2 data3 data1 data2 data3 data1 data2 data3

我正在考虑将数据安排在mysql数据库中,然后执行一个查询来简化过程,但我无法弄清楚如何做一些事情。

我可以像这样安排数据:数据库模式; fields:varchar(50) 栏目名称=日期:10-30-09(星期一至五);

该查询将很简单,然后:“SELECT * FROM table1”

数据需要水平扩展,因此需要每天创建一个新列。

如果我按照这样的日期来安排数据,我不确定查询会将输出变为日期列:

id name date 1 data1 10-28-09 2 data1 10-28-09 3 data1 10-28-09 4 data2 10-29-09 5 data2 10-29-09 6 data2 10-29-09 7 data3 10-30-09 8 data3 10-30-09 9 data3 10-30-09

我正在考虑添加一个排序列,并为每个日期的所有行增加1-20,但那么您需要以某种方式加入每个日期,输出结果会是:

10-28-09 10-29-09 10-30-09 data1 data2 data3 data1 data2 data3 data1 data2 data3

I have 3 text files each of which contains a list of 20 items. A new column will be added per new day.

I'd like to display these items in a spreadsheet or spreadsheet type layout with each column adjacent to the next.

Spreadsheet output like:

10-28-09 10-29-09 10-30-09 data1 data2 data3 data1 data2 data3 data1 data2 data3

I'm thinking of arranging the data in a mysql database, and execute a query to simply the process, however I can't figure out how to do a few things.

I can arrange the data like this: DB schema; fields: varchar (50) Columns name = date: 10-30-09 ( mon - fri);

The query would be simple then: "SELECT * FROM table1"

The data needs to expand horizontally so a new column needs to be created by day.

If I was to arrange the data by date like this, I'm not sure what the query would be to get the output into dated columns:

id name date 1 data1 10-28-09 2 data1 10-28-09 3 data1 10-28-09 4 data2 10-29-09 5 data2 10-29-09 6 data2 10-29-09 7 data3 10-30-09 8 data3 10-30-09 9 data3 10-30-09

I was thinking of adding a sort column and increment it 1-20 for all rows per date, but then you would need to join on every date somehow, again the output would be:

10-28-09 10-29-09 10-30-09 data1 data2 data3 data1 data2 data3 data1 data2 data3

最满意答案

您不应该尝试将数据安排在数据库的数据库列中,您应该编写一个前端来安排数据。 你当然不应该每天修改表格来添加一列。

有可能你真正想要做的是在你的数据中有20列,并且每天添加一行。 然后,转换数据对于您的前端来说是相对容易的工作,但从您的问题中不清楚为什么您要这样做。

You shouldn't try to arrange your data in database columns from the database, you should write a front end to arrange the data. You certainly shouldn't be modifying the table every day to add a column.

It's possible that what you really want to do is have 20 columns in your data and add a row each day. Then transposing the data is a relatively easy job for your front end, but it's unclear from your question why you are trying to do this.

更多推荐

本文发布于:2023-07-06 07:38:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1047399.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库中   Display   Database   Columns

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!