Multiplecolumns填充行访问权限

时间:2016-06-30 18:48:27

标签: mysql sql ms-access ms-access-2013

我的情况如下:

 Column 1:Midterm 1 Score      Grade      Column2:Midterm 2 Score      Grade:
     Good                      99           Okay                        75
     Very Good                 98           Great                       99
     Great                     100          Good                        80

是否可以创建一个表(使用查询),这些记录将在一个列表中垂直列出示例:

    Midterm Scores                        Midterm Grade
    Good                                        99
    Very Good                                   98
    Great                                       100
    Okay                                        75
    Great                                       99
    Good                                        80

如果有可能我该怎么做? 感谢

1 个答案:

答案 0 :(得分:0)

您的问题实际上是表设计问题。你应该做的是以更规范的方式重新创建你的表。简单的例子:

MidtermScores:

ID            AutoNumber    PK
MidtermNumber Number
Description   Text
Grade         Number

然后你可以简单地查询表

SELECT Description, Grade
FROM MidtermScores;

SELECT "Midterm" & [MidtermNumber], Description, Grade
FROM MidtermScores;

最后,为了完整起见,这回答了您原来的问题,但这是一条不好的路线:

SELECT MidtermScores.Midterm 1 Score AS Midterm Scores, MidtermScores.Grade AS Midterm Grade
FROM MidtermScores
UNION ALL
SELECT MidtermScores.Midterm 2 Score AS Midterm Scores, MidtermScores.[Grade:] AS Midterm Grade
FROM MidtermScores