下面图老师小编跟大家分享学习MySQL多表操作和备份处理,一起来学习下过程究竟如何进行吧!喜欢就赶紧收藏起来哦~
【 tulaoshi.com - 编程语言 】
前面我们熟悉了数据库和数据库表的基本操作,现在我们再来看看如何操作多个表。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 | +----------+------+------------+-----------+
mysql create table title(writer varchar(20) not null, - title varchar(40) not null, - senddate date); 向该表中填加记录,最后表的内容如下: ccid_nobrtable width="400" border="1" cellspacing="0" cellpadding="2" bordercolorlight = "black" bordercolordark = "#FFFFFF" align="center"trtd bgcolor="e6e6e6" class="code" style="font-size:9pt"preccid_code 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)
mysql SELECT name,sex,title FROM mytable,title - WHERE name=writer AND name=′abccs′; +-------+------+-------+ | name | sex | title | +-------+------+-------+ | abccs | f | a1 | | abccs | f | a2 | +-------+------+-------+
mysql select title,writer,birthaddr,birth from mytable,title - where mytable.name=title.writer and title=′a2′; +-------+--------+-----------+------------+ | title | writer | birthaddr | birth | +-------+--------+-----------+------------+ | a2 | abccs | china | 1977-07-07 | +-------+--------+-----------+------------+
mysql select * from mytable; +----------+------+------------+-----------+--------+ | name | sex | birth | birthaddr | single | +----------+------+------------+-----------+--------+ | abccs |f | 1977-07-07 | china | y | | mary |f | 1978-12-12 | usa | NULL | | tom |m | 1970-09-02 | usa | NULL | +----------+------+------------+-----------+--------+
mysql insert into mytable - values (′abc′,′f′,′1966-08-17′,′china′,′n′); Query OK, 1 row affected (0.05 sec)
mysql select * from mytable; +----------+------+------------+-----------+--------+ | name | sex | birth | birthaddr | single | +----------+------+------------+-----------+--------+ | abccs |f | 1977-07-07 | china | y | | mary |f | 1978-12-12 | usa | NULL | | tom |m | 1970-09-02 | usa | NULL | | abc |f | 1966-08-17 | china | n | +----------+------+------------+-----------+--------+
mysql select * from mytable; +----------+------+------------+-----------+--------+ | name | sex | birth | birthaddr | single | +----------+------+------------+-----------+--------+ | abccs |f | 1977-07-07 | china | y | | mary |f | 1978-12-12 | usa | NULL | | tom |m | 1970-09-02 | usa | NULL | +----------+------+------------+-----------+--------+
use abccs; select * from mytable; select name,sex from mytable where name=′abccs′;
来源:http://www.tulaoshi.com/n/20160219/1617645.html
看过《学习MySQL多表操作和备份处理》的人还看了以下文章 更多>>