我使用'college2'数据库中的命令行创建了4个表:
mysql> SHOW TABLES;
+--------------------+
| Tables_in_college2 |
+--------------------+
| course |
| enrolment |
| enrolment_status |
| student |
+--------------------+
4 rows in set (0.00 sec)
表enrolment_status
从表enrolment
开始计算每门课程中注册学生的数量,并使用以下命令行创建:
CREATE TABLE enrolment_status SELECT code, count(id) FROM enrolment
GROUP BY code;
当我向enrolment
表插入新记录时,我希望在enrolment_status
表中看到相应的更改,但enrolment_status
表保持不变,不反映新插入的记录。< / p>
我该如何纠正这个?
答案 0 :(得分:2)
将 void FindAndReplace(Microsoft.Office.Interop.Word.Application doc, string findText, string replaceWithText)
{
if (replaceWithText.Length > 255)
{
FindAndReplace(doc, findText, findText + replaceWithText.Substring(255));
replaceWithText = replaceWithText.Substring(0, 255);
}
//options
object matchCase = false;
object matchWholeWord = true;
object matchWildCards = false;
object matchSoundsLike = false;
object matchAllWordForms = false;
object forward = true;
object format = false;
object matchKashida = false;
object matchDiacritics = false;
object matchAlefHamza = false;
object matchControl = false;
object read_only = false;
object visible = true;
object replace = 2;
object wrap = 1;
//execute find and replace
doc.Selection.Find.Execute(findText, ref matchCase, ref matchWholeWord,
ref matchWildCards, ref matchSoundsLike, ref matchAllWordForms, ref forward, ref wrap, ref format, replaceWithText, ref replace,
ref matchKashida, ref matchDiacritics, ref matchAlefHamza, ref matchControl);
}
与另一个表一起用作数据源,为目标表提供源表中数据的一次性快照。因此,后续插入CREATE TABLE
不会反映在enrolment
中。与您的想法最接近的可能是在enrolment_status
表格上创建一个视图:
enrolment
视图CREATE VIEW enrolment_view AS
SELECT code, COUNT(id)
FROM enrolment
GROUP BY code;
将反映对基础表enrolment_view
的更改,包括新插入的记录。但是,不可能将记录直接插入到该视图中。