Created
June 27, 2016 08:02
-
-
Save otakustay/c0278141a8f74e3d2a744df8d32c48d2 to your computer and use it in GitHub Desktop.
mysql in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql> show columns in `order`; | |
+----------+---------+------+-----+---------+----------------+ | |
| Field | Type | Null | Key | Default | Extra | | |
+----------+---------+------+-----+---------+----------------+ | |
| id | int(11) | NO | PRI | NULL | auto_increment | | |
| product | int(11) | NO | | NULL | | | |
| quantity | int(11) | NO | | NULL | | | |
+----------+---------+------+-----+---------+----------------+ | |
3 rows in set (0.01 sec) | |
mysql> show columns in `product`; | |
+----------+-------------+------+-----+---------+----------------+ | |
| Field | Type | Null | Key | Default | Extra | | |
+----------+-------------+------+-----+---------+----------------+ | |
| id | int(11) | NO | PRI | NULL | auto_increment | | |
| category | int(11) | NO | MUL | NULL | | | |
| name | varchar(20) | NO | | NULL | | | |
+----------+-------------+------+-----+---------+----------------+ | |
3 rows in set (0.00 sec) | |
mysql> explain select * from `order` where id in (select id from product where category = 4); | |
+----+-------------+---------+------------+--------+----------------------+---------+---------+---------------+------+----------+-------------+ | |
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | | |
+----+-------------+---------+------------+--------+----------------------+---------+---------+---------------+------+----------+-------------+ | |
| 1 | SIMPLE | order | NULL | ALL | PRIMARY | NULL | NULL | NULL | 1 | 100.00 | NULL | | |
| 1 | SIMPLE | product | NULL | eq_ref | PRIMARY,idx_category | PRIMARY | 4 | test.order.id | 1 | 100.00 | Using where | | |
+----+-------------+---------+------------+--------+----------------------+---------+---------+---------------+------+----------+-------------+ | |
2 rows in set, 1 warning (0.01 sec) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment