Ç°ÃæÎÒÃÇÊìϤÁËÊý¾Ý¿âºÍÊý¾Ý¿â±íµÄ»ù±¾²Ù×÷£¬ÏÖÔÚÎÒÃÇÔÙÀ´¿´¿´ÈçºÎ²Ù×÷¶à¸ö±í¡£
ÔÚÒ»¸öÊý¾Ý¿âÖУ¬¿ÉÄÜ´æÔÚ¶à¸ö±í£¬ÕâЩ±í¶¼ÊÇÏ໥¹ØÁªµÄ¡£ÎÒÃǼÌÐøʹÓÃÇ°ÃæµÄÀý×Ó¡£Ç°Ã潨Á¢µÄ±íÖаüº¬ÁËÔ±¹¤µÄһЩ»ù±¾ÐÅÏ¢£¬ÈçÐÕÃû¡¢ÐԱ𡢳öÉúÈÕÆÚ¡¢³öÉúµØ¡£ÎÒÃÇÔÙ´´½¨Ò»¸ö±í£¬¸Ã±íÓÃÓÚÃèÊöÔ±¹¤Ëù·¢±íµÄÎÄÕ£¬ÄÚÈÝ°üÀ¨×÷ÕßÐÕÃû¡¢ÎÄÕ±êÌâ¡¢·¢±íÈÕÆÚ¡£
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)
3¡¢¶à±í²éѯ
ÏÖÔÚÎÒÃÇÓÐÁËÁ½¸ö±í: mytable ºÍ title¡£ÀûÓÃÕâÁ½¸ö±íÎÒÃÇ¿ÉÒÔ½øÐÐ×éºÏ²éѯ£º
ÀýÈçÎÒÃÇÒª²éѯ×÷ÕßabccsµÄÐÕÃû¡¢ÐÔ±ð¡¢ÎÄÕ£º
mysql> SELECT name,sex,title FROM mytable,title
-> WHERE name=writer AND name='abccs';
+-------+------+-------+
| name | sex | title |
+-------+------+-------+
| abccs | f| a1|
| abccs | f| a2|
+-------+------+-------+
ÉÏÃæÀý×ÓÖУ¬ÓÉÓÚ×÷ÕßÐÕÃû¡¢ÐÔ±ð¡¢ÎÄռǼÔÚÁ½¸ö²»Í¬±íÄÚ£¬Òò´Ë±ØÐëʹÓÃ×éºÏÀ´½øÐвéѯ¡£±ØÐëÒªÖ¸¶¨Ò»¸ö±íÖеļǼÈçºÎÓëÆäËü±íÖеļǼ½øÐÐÆ¥Åä¡£
×¢Ò⣺Èç¹ûµÚ¶þ¸ö±ítitleÖеÄwriterÁÐҲȡÃûΪname£¨Óëmytable±íÖеÄnameÁÐÏàͬ£©¶ø²»ÊÇwriterʱ£¬¾Í±ØÐëÓÃmytable.nameºÍtitle.name±íʾ£¬ÒÔʾÇø±ð¡£
ÔÙ¾ÙÒ»¸öÀý×Ó£¬ÓÃÓÚ²éѯÎÄÕÂ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 |
+-------+--------+-----------+------------+
yuemao ÓÚ 2009-03-27 16:47:40·¢±í:
ѧϰÁË
jerry520 ÓÚ 2009-03-27 16:45:46·¢±í:
ºÇºÇ,²»´í°¡!ѧϰÁË.
Çç ÓÚ 2005-10-22 00:17:55·¢±í:
Ö§³Ö
koov ÓÚ 2005-09-22 00:54:07·¢±í:
ÊܽÌ
yo ÓÚ 2005-09-09 00:31:35·¢±í:
ÊܽÌÁË