mytableSELECT * FROM mytable;
+----------+------+------------+-----------+
| name | sex | birth | birthaddr |
+----------+------+------------+-----------+
| abccs | f | 1977-07-07 | china |
| mary | f | 1978-12-12 | usa |
| tom | m | 1970-09-02 | usa |
+----------+------+------------+-----------+
titleCREATE TABLE title (
writer VARCHAR(20) NOT NULL,
title VARCHAR(40) NOT NULL,
senddate DATE
);
插入數據後:
SELECT * FROM title;
+--------+-------+------------+
| writer | title | senddate |
+--------+-------+------------+
| abccs | a1 | 2000-01-23 |
| mary | b1 | 1998-03-21 |
| abccs | a2 | 2000-12-04 |
| tom | c1 | 1992-05-16 |
| tom | c2 | 1999-12-12 |
+--------+-------+------------+
SELECT name, sex, title
FROM mytable, title
WHERE name = writer AND name = 'abccs';
+-------+------+-------+
| name | sex | title |
+-------+------+-------+
| abccs | f | a1 |
| abccs | f | a2 |
+-------+------+-------+
INNER JOIN ... ON)WHERE同時承擔關聯條件與過濾條件FROM mytable JOIN title ON mytable.name = title.writer,語義更清晰、易維護