PR

select 問い合わせ postgres ①

tableからlistの行を取り出し
select list from table;


table から全ての行を取り出し
select * from table;

select cat,a + b from table;
a と b は数値型と仮定する。

select 100 * 200;
電卓として使用できる

select random();
random()という関数を呼び出す。

select * from table1,table2

select * from table1 cross join table2;
クロス結合

select * from table1 inner join table2 on true;

select * from table1 cross join table2;

select * from table1 inner join table2 on table1.number = table2.number;

select * from table1 inner join table2 using (number);
カラムnumber をキーにして、結合

select * from table1 natural inner join table2;
naturalはusingの略式です。

select * from table1 left join table2 on table1.number = table2.number;

select * from table1 left join table2 using (number);

select * from table1 right join table2 on table1.number = table2.number;

select * from table1 full join table2 on table1.number = table2.number;









PR


INDEX

トラックバック(0)

トラックバックURL: http://websky21.com/MT/mt-tb.cgi/259

このブログ記事について

このページは、naotoが2009年1月15日 01:00に書いたブログ記事です。

次のブログ記事は「select as 別名」です。

最近のコンテンツはインデックスページで見られます。過去に書かれたものはアーカイブのページで見られます。

カテゴリ

ウェブページ

Powered by Movable Type 4.27-ja