简体   繁体   English

"如何在同一个表中将多行合并为一行但具有不同的列?"

[英]How do I combine multiple rows into one row in the same table but with different columns?

First up, my goal is that some job applicant should be able to upload some files and then submit the application.首先,我的目标是一些求职者应该能够上传一些文件,然后提交申请。 A HR person in the company should be able to then export the data and the files.公司的人力资源人员应该能够导出数据和文件。

Basically, I have one table with the data from some job applications (Name, Email etc.).基本上,我有一张表,其中包含一些工作申请(姓名、电子邮件等)的数据。

ApplicantID申请人ID<\/th> Name名称<\/th> Email电子邮件<\/th> Column 3第 3 栏<\/th><\/tr><\/thead>
1 1<\/td> Foo<\/td> Bar酒吧<\/td> Yo<\/td><\/tr>
2 2<\/td> Foo<\/td> Bar酒吧<\/td> Yo<\/td><\/tr>
3 3<\/td> Foo<\/td> Bar酒吧<\/td> Yo<\/td><\/tr><\/tbody><\/table>

I have another table with the relative paths and the file names of some files the applicant has uploaded.我有另一个表格,其中包含申请人上传的一些文件的相对路径和文件名。 Because of my somewhat clunky frontend design, the file table looks like this (Only the file names are represented):由于我的前端设计有些笨拙,文件表如下所示(仅表示文件名):

FileID文件ID<\/th> Letter<\/th> CV简历<\/th> Qualifications资格<\/th><\/tr><\/thead>
1 1<\/td> Foo<\/td> NULL空值<\/td> NULL空值<\/td><\/tr>
2 2<\/td> NULL空值<\/td> Bar酒吧<\/td> NULL空值<\/td><\/tr>
3 3<\/td> NULL空值<\/td> NULL空值<\/td> Yo<\/td><\/tr><\/tbody><\/table>

Is there any way to get it like this with a query?有没有办法通过查询得到这样的结果?

Column 1第 1 列<\/th> Column 2第 2 栏<\/th> Column 3第 3 栏<\/th><\/tr><\/thead>
Foo<\/td> Bar酒吧<\/td> Yo<\/td><\/tr><\/tbody><\/table>

I've had the idea of using a third mxn table like this:我有使用这样的第三个 mxn 表的想法:

ApplicantID申请人ID<\/th> FileID文件ID<\/th><\/tr><\/thead>
1 1<\/td> 1 1<\/td><\/tr>
1 1<\/td> 2 2<\/td><\/tr>
1 1<\/td> 3 3<\/td><\/tr><\/tbody><\/table>

But here comes the question of how I can get the latest 3 added rows and get individual columns.但是问题来了,我如何获得最新添加的 3 行并获得单个列。

"

您可以使用JOIN<\/strong>连接三个表并获得所需的列....但请确保在设计表时遵循规范化

"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM