多表操作
在一个数据库中,可能存在多个表,这些表都是相互关联的。咱们
继续运用
前面的例子。前面建立的表中包含了员工的一些基本信息,如姓名、性别、出生日期、出生地。咱们
再建立
一个表,该表用于描述员工所揭晓
的文章,内容包含
作者姓名、文章标题、揭晓
日期。
1、查看第一个表mytable的内容:
mysql> select * from mytable; +----------+------+------------+-----------+ name sex birth birthaddr +----------+------+------------+-----------+ abccs f 1977-07-07 china mary f 1978-12-12 usa tom m 1970-09-02 usa +----------+------+------------+-----------+
2、建立
第二个表title(包含
作者、文章标题、揭晓
日期):
mysql> create table title(writer varchar(20) not null, -> title varchar(40) not null, -> senddate date); 向该表中填加记载
,结尾
表的内容如下:
mysql> 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 +--------+-------+------------+ 5 rows in set (0.00sec) |