From 2f43b660db1ca6434d9c1bc21703cc64d9853f2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=98=8E=E5=81=A5?= <2161737470@qq.com> Date: Wed, 25 Oct 2023 11:15:27 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E5=8D=81=E5=85=AD=E6=AC=A1?= =?UTF-8?q?=E7=AC=94=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\345\205\27050\351\201\223\351\242\230.md" | 2 +- ...QL\345\244\215\344\271\240\344\270\200.md" | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) rename "04 \346\235\216\346\230\216\345\201\245/20231020 \351\207\221\345\205\27050\351\201\223\351\242\230.md" => "04 \346\235\216\346\230\216\345\201\245/20231020 \347\273\217\345\205\27050\351\201\223\351\242\230.md" (99%) create mode 100644 "04 \346\235\216\346\230\216\345\201\245/20231024 MySQL\345\244\215\344\271\240\344\270\200.md" diff --git "a/04 \346\235\216\346\230\216\345\201\245/20231020 \351\207\221\345\205\27050\351\201\223\351\242\230.md" "b/04 \346\235\216\346\230\216\345\201\245/20231020 \347\273\217\345\205\27050\351\201\223\351\242\230.md" similarity index 99% rename from "04 \346\235\216\346\230\216\345\201\245/20231020 \351\207\221\345\205\27050\351\201\223\351\242\230.md" rename to "04 \346\235\216\346\230\216\345\201\245/20231020 \347\273\217\345\205\27050\351\201\223\351\242\230.md" index 0d76e62..699c3eb 100644 --- "a/04 \346\235\216\346\230\216\345\201\245/20231020 \351\207\221\345\205\27050\351\201\223\351\242\230.md" +++ "b/04 \346\235\216\346\230\216\345\201\245/20231020 \347\273\217\345\205\27050\351\201\223\351\242\230.md" @@ -1,4 +1,4 @@ -#### 金典五十道题 +#### 经典五十道题 ~~~ mysql create database text01 charset utf8; diff --git "a/04 \346\235\216\346\230\216\345\201\245/20231024 MySQL\345\244\215\344\271\240\344\270\200.md" "b/04 \346\235\216\346\230\216\345\201\245/20231024 MySQL\345\244\215\344\271\240\344\270\200.md" new file mode 100644 index 0000000..37077e5 --- /dev/null +++ "b/04 \346\235\216\346\230\216\345\201\245/20231024 MySQL\345\244\215\344\271\240\344\270\200.md" @@ -0,0 +1,21 @@ +### 子查询三大用法 + + 1. 放在 select 后当列使用,要求子查询单列单行。 + 1. 放在 from 后面 当表使用,要给子查询取别名。 + 3. 放在 where 后面当条件使用 + - 单列单行:此时条件可以直接用 = > < <> 等。 + - 单列多行:就需要使用 in any all 等。 + +### count 的使用 + + 1. count(*) 查询所有,包括 null + 1. count(常量) 查询所有,包括 null + 1. count(列名) 返回列名指定列的记录数,不包括 null + +##### count(*)&count(1)&count(列名)执行效率比较: + +- 如果列为主键,count(列名)效率优于count(1) +- 如果列不为主键,count(1)效率优于count(列名) +- 如果表中存在主键,count(主键列名)效率最优 +- 如果表中只有一列,则count(*)效率最优 +- 如果表有多列,且不存在主键,则count(1)效率优于count(*) \ No newline at end of file -- Gitee