mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-07 00:11:41 +08:00
批量更新数据
This commit is contained in:
@@ -12,12 +12,12 @@
|
||||
"translatedContent": "<p>学生表: <code>Students</code></p>\n\n<pre>\n+---------------+---------+\n| Column Name | Type |\n+---------------+---------+\n| student_id | int |\n| student_name | varchar |\n+---------------+---------+\n在 SQL 中,主键为 student_id(学生ID)。\n该表内的每一行都记录有学校一名学生的信息。\n</pre>\n\n<p> </p>\n\n<p>科目表: <code>Subjects</code></p>\n\n<pre>\n+--------------+---------+\n| Column Name | Type |\n+--------------+---------+\n| subject_name | varchar |\n+--------------+---------+\n在 SQL 中,主键为 subject_name(科目名称)。\n每一行记录学校的一门科目名称。\n</pre>\n\n<p> </p>\n\n<p>考试表: <code>Examinations</code></p>\n\n<pre>\n+--------------+---------+\n| Column Name | Type |\n+--------------+---------+\n| student_id | int |\n| subject_name | varchar |\n+--------------+---------+\n这个表可能包含重复数据(换句话说,在 SQL 中,这个表没有主键)。\n学生表里的一个学生修读科目表里的每一门科目。\n这张考试表的每一行记录就表示学生表里的某个学生参加了一次科目表里某门科目的测试。\n</pre>\n\n<p> </p>\n\n<p>查询出每个学生参加每一门科目测试的次数,结果按 <code>student_id</code> 和 <code>subject_name</code> 排序。</p>\n\n<p>查询结构格式如下所示。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<strong>输入:</strong>\nStudents table:\n+------------+--------------+\n| student_id | student_name |\n+------------+--------------+\n| 1 | Alice |\n| 2 | Bob |\n| 13 | John |\n| 6 | Alex |\n+------------+--------------+\nSubjects table:\n+--------------+\n| subject_name |\n+--------------+\n| Math |\n| Physics |\n| Programming |\n+--------------+\nExaminations table:\n+------------+--------------+\n| student_id | subject_name |\n+------------+--------------+\n| 1 | Math |\n| 1 | Physics |\n| 1 | Programming |\n| 2 | Programming |\n| 1 | Physics |\n| 1 | Math |\n| 13 | Math |\n| 13 | Programming |\n| 13 | Physics |\n| 2 | Math |\n| 1 | Math |\n+------------+--------------+\n<strong>输出:</strong>\n+------------+--------------+--------------+----------------+\n| student_id | student_name | subject_name | attended_exams |\n+------------+--------------+--------------+----------------+\n| 1 | Alice | Math | 3 |\n| 1 | Alice | Physics | 2 |\n| 1 | Alice | Programming | 1 |\n| 2 | Bob | Math | 1 |\n| 2 | Bob | Physics | 0 |\n| 2 | Bob | Programming | 1 |\n| 6 | Alex | Math | 0 |\n| 6 | Alex | Physics | 0 |\n| 6 | Alex | Programming | 0 |\n| 13 | John | Math | 1 |\n| 13 | John | Physics | 1 |\n| 13 | John | Programming | 1 |\n+------------+--------------+--------------+----------------+\n<strong>解释:</strong>\n结果表需包含所有学生和所有科目(即便测试次数为0):\nAlice 参加了 3 次数学测试, 2 次物理测试,以及 1 次编程测试;\nBob 参加了 1 次数学测试, 1 次编程测试,没有参加物理测试;\nAlex 啥测试都没参加;\nJohn 参加了数学、物理、编程测试各 1 次。\n</pre>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 220,
|
||||
"likes": 343,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"contributors": [],
|
||||
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}",
|
||||
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false, \"cangjie\": false}",
|
||||
"topicTags": [
|
||||
{
|
||||
"name": "Database",
|
||||
@@ -59,7 +59,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"36K\", \"totalSubmission\": \"72.6K\", \"totalAcceptedRaw\": 35962, \"totalSubmissionRaw\": 72633, \"acRate\": \"49.5%\"}",
|
||||
"stats": "{\"totalAccepted\": \"75.7K\", \"totalSubmission\": \"140.4K\", \"totalAcceptedRaw\": 75701, \"totalSubmissionRaw\": 140436, \"acRate\": \"53.9%\"}",
|
||||
"hints": [],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
@@ -94,7 +94,7 @@
|
||||
"insert into Examinations (student_id, subject_name) values ('1', 'Math')"
|
||||
],
|
||||
"enableRunCode": true,
|
||||
"envInfo": "{\"mysql\":[\"MySQL\",\"<p>\\u7248\\u672c\\uff1a<code>MySQL 8.0<\\/code><\\/p>\"],\"mssql\":[\"MS SQL Server\",\"<p>mssql server 2019.<\\/p>\"],\"oraclesql\":[\"Oracle\",\"<p>Oracle Sql 11.2.<\\/p>\"],\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"],\"postgresql\":[\"PostgreSQL\",\"<p>PostgreSQL 16<\\/p>\"]}",
|
||||
"envInfo": "{\"mysql\":[\"MySQL\",\"<p>\\u7248\\u672c\\uff1a<code>MySQL 8.0<\\/code><\\/p>\"],\"mssql\":[\"MS SQL Server\",\"<p>mssql server 2019.<\\/p>\"],\"oraclesql\":[\"Oracle\",\"<p>Oracle Sql 11.2.<\\/p>\"],\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.2.2 and NumPy 1.26.4<\\/p>\"],\"postgresql\":[\"PostgreSQL\",\"<p>PostgreSQL 16<\\/p>\"]}",
|
||||
"book": null,
|
||||
"isSubscribed": false,
|
||||
"isDailyQuestion": false,
|
||||
|
Reference in New Issue
Block a user