�����ޤǤ��䤤��碌�ϡ����٤� 1 �ĤΥơ��֥�ˤΤߥ������������ΤǤ������䤤��碌�ϡ����٤�ʣ���Υơ��֥�˥����������뤳�Ȥ⡢Ʊ���˥ơ��֥����ʣ���ιԤν�����Ԥ����ʤɡ�Ʊ���ơ��֥�˥����������뤳�Ȥ��ǽ�Ǥ������٤�Ʊ��Υơ��֥�ޤ���ʣ���Υơ��֥��ʣ���ιԤ˥������������䤤��碌�ϡ� ��� �䤤��碌�ȸƤФ�ޤ����㤨�С���Ϣ�����ԻԤΰ��־���ݥǡ����Ȱ���ɽ����������礬���ޤ������Τ���ˤϡ�weather �ơ��֥�γƹԤ� city ����ȡ�cities �ơ��֥�����ƤιԤ� name �����Ӥ���ξ�Ԥ��ͤ����פ���Ԥ��Ȥ߹�碌�����ʤ���Фʤ�ޤ���
Note: ����ϳ�ǰŪ�ʥ�ǥ�Ǥ����ºݤη��Ϥ�äȸ�ΨŪ����ˡ�ǹԤ��ޤ���������������ϥ桼�������Ƚ��ޤ���
����ϡ��ʲ����䤤��碌�ˤ�äƹԤ����Ȥ��Ǥ��ޤ���
SELECT * FROM weather, cities WHERE city = name;
city | temp_lo | temp_hi | prcp | date | name | location ---------------+---------+---------+------+------------+---------------+----------- San Francisco | 46 | 50 | 0.25 | 1994-11-27 | San Francisco | (-194,53) San Francisco | 43 | 57 | 0 | 1994-11-29 | San Francisco | (-194,53) (2 rows)
���η�̤��� 2 �ĤΤ��Ȥ�Ƚ��ޤ���
Hayward �ԤˤĤ��Ƥη�̹ԤϤ���ޤ���cities �ơ��֥�ˤ� Hayward �˰��פ�����ܤ��ʤ������κݤ� weather �ơ��֥���ΰ��פ��ʤ��Ԥ�̵�뤵��뤫��Ǥ�����ñ�ˤɤΤ褦�ˤ��줬�ʤ����Τ��Ƥߤޤ��礦��
�Ի�̾����� 2 �Ĥ�����ޤ���weather �ơ��֥�� cities �ơ��֥����Υꥹ�Ȥ�Ϣ�뤵��Ƥ��뤿�ᤳ�Τ褦�ˤʤ�ޤ����������������餯 * ��Ȥ鷺������Ū�˽�����Υꥹ�Ȥ���ꤹ�뤳�Ȥˤʤ�ޤ��Τǡ��ºݤ����˾���ΤǤϤ���ޤ���
SELECT city, temp_lo, temp_hi, prcp, date, location FROM weather, cities WHERE city = name;
����: WHERE ����ά�������Τ����䤤��碌�ΰ�̣��ͤ��Ʋ�������
��Ϥ��줾��ۤʤ�̾���Ǥ��Τǡ��ѡ����ϼ�ưŪ�ˤɤΥơ��֥����Ƚ�ǤǤ��ޤ���������������䤤��碌�Ǥϡ��ʲ��Τ褦����̾�����˻��ꤹ������ᤷ�ޤ���
SELECT weather.city, weather.temp_lo, weather.temp_hi, weather.prcp, weather.date, cities.location FROM weather, cities WHERE cities.name = weather.city;
�����Ǽ����褦�ʷ���䤤��碌�ϡ��ʲ��Τ褦���̤η���ɽ�����Ȥ��Ǥ��ޤ���
SELECT * FROM weather INNER JOIN cities ON (weather.city = cities.name);
���ι�ʸ�������������Ū�˻��Ѥ�����ΤǤϤ���ޤ����ʹߤ��������褯����Ǥ���褦�ˤ����Ǽ����ޤ���
�����ǡ��ɤΤ褦�ˤ���� Hayward �Υ쥳���ɤ����뤳�Ȥ��Ǥ���褦�ˤʤ�ΤǤ��礦�����¹Ԥ������䤤��碌�ϡ�weather ������ƹԤ��Ф��ơ� cities �Ԥ˰��פ��뤫��Ƚ�Ǥ����ΤǤ������פ��ʤ��Ԥ����ä���硢 cities �ơ��֥�������ʬ�餫��"������"���֤����������ΤǤ������μ���䤤��碌����������ȸƤФ�ޤ��ʤ���ޤǼ����Ƥ��������������Ǥ��ˡ��ʲ��Τ褦�ʥ��ޥ�ɤˤʤ�ޤ���
SELECT * FROM weather LEFT OUTER JOIN cities ON (weather.city = cities.name); city | temp_lo | temp_hi | prcp | date | name | location ---------------+---------+---------+------+------------+---------------+----------- Hayward | 37 | 54 | | 1994-11-29 | | San Francisco | 46 | 50 | 0.25 | 1994-11-27 | San Francisco | (-194,53) San Francisco | 43 | 57 | 0 | 1994-11-29 | San Francisco | (-194,53) (3 rows)
�����䤤��碌�� ��������� �ȸƤФ�ޤ������黻�Ҥκ�¦�˻��ꤷ���ơ��֥�γƹԤ�����Ǥ���ٽ��Ϥ��졢�����ǡ���¦�Υơ��֥�Ǥϡ���¦�Υơ��֥�ιԤ˰��פ����ΤΤߤ����Ϥ���뤫��Ǥ�����¦�Υơ��֥�˰��פ��ʤ�����¦�Υơ��֥�ιԤ���Ϥ��������¦�Υơ��֥����϶��Ρ�NULL���ͤ��ִ�����ޤ���
����: ���������䴰����������¸�ߤ��ޤ�������餬����Ԥ�����ͤ��Ʋ�������
�ơ��֥��ʬ���Ȥ��Ф��Ʒ�礵���뤳�Ȥ��Ǥ��ޤ�������� ���ʷ�� �ȸƤФ�ޤ�����Ȥ��ơ�¾�ε��ݥǡ����β����ϰ���ˤ��뵤�ݥǡ��������Ƽ��Ф����Ȥ�ͤ��ޤ��� weather �ƹԤ� temp_lo �� temp_hi ��¾�� weather �Ԥ� temp_lo �� temp_hi ��Ȥ���Ӥ��ʤ���Фʤ�ޤ��ʲ����䤤��碌����Ѥ��ƹԤ��ޤ���
SELECT W1.city, W1.temp_lo AS low, W1.temp_hi AS high, W2.city, W2.temp_lo AS low, W2.temp_hi AS high FROM weather W1, weather W2 WHERE W1.temp_lo < W2.temp_lo AND W1.temp_hi > W2.temp_hi; city | low | high | city | low | high ---------------+-----+------+---------------+-----+------ San Francisco | 43 | 57 | San Francisco | 46 | 50 Hayward | 37 | 54 | San Francisco | 46 | 50 (2 rows)
�����ǡ����κ�¦�ȱ�¦����̤��뤳�Ȥ��Ǥ���褦�ˡ�weather �ơ��֥�� W1 �� W2 �Ȥ�����٥��Ĥ��Ƥ��ޤ����ޤ������Ϥʤ����뤿��ˡ�¾���䤤��碌�Ǥ⤳�μ����̾����ѤǤ��ޤ����ʲ�������ޤ���
SELECT * FROM weather w, cities c WHERE w.city = c.name;
�������ä����ξ�ά�Ϥ��ʤ��ɤ��Ԥ��ޤ���