NATURAL INNER sample : Natural Join « Table Joins « PostgreSQL






NATURAL INNER sample


postgres=#
postgres=# CREATE TABLE t1 (
postgres(#     num         int,
postgres(#     name       varchar(10)
postgres(# );
CREATE TABLE
postgres=#
postgres=# insert into t1 values(1,'a');
INSERT 0 1
postgres=# insert into t1 values(2,'b');
INSERT 0 1
postgres=# insert into t1 values(3,'c');
INSERT 0 1
postgres=#
postgres=# CREATE TABLE t2 (
postgres(#     num         int,
postgres(#     name       varchar(10)
postgres(# );
CREATE TABLE
postgres=#
postgres=# insert into t2 values(1,'xxx');
INSERT 0 1
postgres=# insert into t2 values(3,'yyy');
INSERT 0 1
postgres=# insert into t2 values(5,'zzz');
INSERT 0 1
postgres=#
postgres=# SELECT * FROM t1 NATURAL INNER JOIN t2;
 num | name
-----+------
(0 rows)

postgres=#
postgres=# drop table t1;
DROP TABLE
postgres=# drop table t2;
DROP TABLE
postgres=#
           
       








Related examples in the same category

1.Natural join two tables with order by and group by
2.Using LIMIT for Natural Join