select * from emp,dept;
笛卡尔积 垃圾:把表里面所有的数据查询出来,会造成大量的数据垃圾。
解决方法:使用内连接(关联字段查询)
select * from emp,dept where emp.dep_id = dept.did;
Microsoft Windows [版本 10.0.19044.2130]
(c) Microsoft Corporation。保留所有权利。
C:\Users\31943>mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 33
Server version: 5.7.17-log MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| day02 |
| itheima_admin |
| mysql |
| performance_schema |
| sys |
+--------------------+
6 rows in set (0.00 sec)
mysql> use day02;
Database changed
mysql> select * from emp,dept;
+----+--------+--------+--------+------------+-------