MS Access创建查询
让我们在本章中了解如何创建查询。
创建更新查询
您可以使用更新查询更改表中的数据,并且可以使用更新查询来输入条件以指定应更新哪些行。更新查询为您提供在执行更新之前查看更新的数据的机会。让我们再次转到“创建”选项卡,然后单击“查询设计”。

在“表”选项卡的“显示表”对话框中,双击tblEmployees表,然后关闭对话框。

在“设计”选项卡上的“查询类型”组中,单击“更新”,然后双击要更新值的字段。比如说,我们要将“Rex”的FirstName更新为“Max”。

在“设计”网格的“更新”行中,输入更新的值,然后在“条件”行中添加要更新的原始值并运行查询。这将显示确认消息。

单击“Yes”并转到数据表视图,您将看到第一个记录 - FirstName现在更新为“Max”。

创建删除查询
您可以使用删除查询从表中删除数据,您可以使用删除查询来输入条件以指定应该删除哪些行。删除查询为您提供了在执行删除之前查看将要删除的行的机会。让我们再次转到“创建”选项卡,然后单击“查询设计”。

在“显示表”对话框的“表”选项卡中,双击tblEmployees表,然后关闭对话框。

在“设计”选项卡上的“查询类型”组中,单击删除,然后双击EmployeeID。

在设计网格的“条件”行中,键入11.这里,我们要删除EmployeeID为11的员工。

现在让我们来运行查询。此查询将显示确认消息。

单击“Yes”并转到您的数据表视图,您将看到指定的员工记录现在已删除。

创建生成表查询
您可以使用生成表查询从存储在其他表中的数据创建新表。让我们再次转到“创建”选项卡,然后单击“查询设计”。

在“表”选项卡的“显示表”对话框中,双击tblEmployees表,然后关闭对话框。

选择要复制到另一个表的所有字段。

在“查询类型”中,选择“生成表”选项按钮。

您将看到以下对话框。输入要创建的新表的名称,然后单击“Yes”。

现在运行查询。

您现在将看到以下消息。

单击“Yes”,您将看到在导航窗格中创建了一个新表。
更多建议: